mirror of
https://github.com/SphericalKat/medium.rip.git
synced 2026-10-25 09:34:22 +00:00
feat: add sample response.json for dev
Signed-off-by: Sphericalkat <amolele@gmail.com>
This commit is contained in:
1 parent
9600c21c5a
commit
848cd514d0
3 files changed
+35
-3
No files matched your search
+15
-2
@@ -1,9 +1,22 @@
|
||||
package routes
|
||||
|
||||
import "github.com/gofiber/fiber/v2"
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/medium.rip/pkg/client"
|
||||
)
|
||||
|
||||
func show(c *fiber.Ctx) error {
|
||||
return nil
|
||||
postId := c.Params("id", "")
|
||||
if postId == "" {
|
||||
return c.Redirect("/")
|
||||
}
|
||||
|
||||
e, err := client.PostData(postId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return c.JSON(e)
|
||||
}
|
||||
|
||||
func index(c *fiber.Ctx) error {
|
||||
|
||||
@@ -2,15 +2,33 @@ package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/medium.rip/internal/config"
|
||||
"github.com/medium.rip/pkg/entities"
|
||||
)
|
||||
|
||||
func PostData(postId string) (*entities.MediumResponse, error) {
|
||||
if config.Conf.Env == "dev" {
|
||||
file, err := os.ReadFile("response.json")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mr, err := entities.UnmarshalMediumResponse(file)
|
||||
if err != nil {
|
||||
log.Printf("Error unmarshalling body from response %v\n", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &mr, nil
|
||||
}
|
||||
|
||||
// http client to post data
|
||||
url := "https://medium.com/_/graphql"
|
||||
method := "POST"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{"data":{"post":{"title":"Pandas AI — The Future of Data Analysis","createdAt":1683185501743,"creator":{"id":"b856005e5ecd","name":"Fareed Khan"},"content":{"bodyModel":{"paragraphs":[{"name":"b238","text":"Pandas AI — The Future of Data Analysis","type":"H3","href":null,"layout":null,"markups":[],"iframe":null,"metadata":null},{"name":"cbfd","text":"","type":"IMG","href":null,"layout":"INSET_CENTER","markups":[],"iframe":null,"metadata":{"id":"1*awdsJFX9yyTGK7Ym9I2TtA.png","originalWidth":1481,"originalHeight":758}},{"name":"2c3a","text":"Imagine being able to talk to your data like it’s your best friend. That’s what Pandas AI does! This Python library has generative artificial intelligence capabilities that can turn your dataframes into conversationalists. No more endless hours of staring at rows and columns.","type":"P","href":null,"layout":null,"markups":[],"iframe":null,"metadata":null},{"name":"a1ee","text":"But don’t worry, Pandas AI is not here to replace your beloved Pandas. It’s here to enhance it! With Pandas AI, you can take your data analysis and manipulation to the next level. Think of it like a superhero sidekick — it’s there to help you save the day and make your life easier.","type":"P","href":null,"layout":null,"markups":[],"iframe":null,"metadata":null},{"name":"5514","text":"The possibilities with Pandas AI are endless. Imagine having a dataframe that can write its own reports, or one that can analyze complex data and provide you with easy-to-understand summaries.","type":"P","href":null,"layout":null,"markups":[],"iframe":null,"metadata":null},{"name":"5171","text":"In this quick guide, you’ll get a step-by-step walkthrough of how to use this cutting-edge library, regardless of your level of experience in the field.","type":"P","href":null,"layout":null,"markups":[],"iframe":null,"metadata":null},{"name":"ab65","text":"Whether you’re an experienced data analyst or a beginner, this guide will equip you with all the tools you need to dive into the world of Pandas AI with confidence. So sit back, relax, and let’s explore the exciting possibilities that Pandas AI has to offer!","type":"P","href":null,"layout":null,"markups":[],"iframe":null,"metadata":null},{"name":"42f1","text":"Official GitHub Repository — https://github.com/gventuri/pandas-ai","type":"P","href":null,"layout":null,"markups":[{"title":"","type":"A","href":"https://github.com/gventuri/pandas-ai","userId":null,"start":29,"end":66,"anchorType":"LINK"},{"title":null,"type":"STRONG","href":null,"userId":null,"start":0,"end":28,"anchorType":null}],"iframe":null,"metadata":null},{"name":"7b4c","text":"Code— https://colab.research.google.com/drive/1rKz7TudOeCeKGHekw7JFNL4sagN9hon-?usp=sharing","type":"P","href":null,"layout":null,"markups":[{"title":"","type":"A","href":"https://colab.research.google.com/drive/1rKz7TudOeCeKGHekw7JFNL4sagN9hon-?usp=sharing","userId":null,"start":6,"end":91,"anchorType":"LINK"},{"title":null,"type":"STRONG","href":null,"userId":null,"start":0,"end":4,"anchorType":null}],"iframe":null,"metadata":null},{"name":"ae7c","text":"Installing Pandas AI using pip","type":"H4","href":null,"layout":null,"markups":[],"iframe":null,"metadata":null},{"name":"51fe","text":"pip install pandasai","type":"PRE","href":null,"layout":null,"markups":[],"iframe":null,"metadata":null},{"name":"4f69","text":"Our DataFrame contains information about various countries, including their GDP (in millions of USD) and happiness index scores. It consists of 10 rows and 3 columns:","type":"P","href":null,"layout":null,"markups":[],"iframe":null,"metadata":null},{"name":"4b06","text":"","type":"IMG","href":null,"layout":"INSET_CENTER","markups":[],"iframe":null,"metadata":{"id":"1*FvevlIS-mnRSvqg2Nq5JnQ.png","originalWidth":925,"originalHeight":809}},{"name":"29ef","text":"Importing PandasAI with OpenAI","type":"H4","href":null,"layout":null,"markups":[],"iframe":null,"metadata":null},{"name":"2656","text":"In the next step, we’ll import the pandasai library that we installed earlier and then import the LLM (Large Language Model) feature. As of May 2023, pandasai only supports the OpenAI model, which we’ll be utilizing understand the data.","type":"P","href":null,"layout":null,"markups":[],"iframe":null,"metadata":null},{"name":"a57a","text":"","type":"IMG","href":null,"layout":"INSET_CENTER","markups":[],"iframe":null,"metadata":{"id":"1*RsVA6lJngSkpSs_BB9yZAg.png","originalWidth":939,"originalHeight":409}},{"name":"e33e","text":"To use the OpenAI API, you must generate your own unique API key. If you haven’t done so already, you can easily create an account on the platform’s official website at platform.openai.com. Once you’ve created your account, you’ll receive an instant $5 credit that can be used to explore and experiment with the API.","type":"P","href":null,"layout":null,"markups":[],"iframe":null,"metadata":null},{"name":"a3ab","text":"Initializing PandasAI and asking Question","typeLine truncated
|
||||
Reference in new issue
Block a user