File size: 1,620 Bytes
6967dd4
 
 
0d9f612
 
6967dd4
 
 
 
 
 
 
d40b7d4
99b345f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6967dd4
 
d2e64c6
6967dd4
 
3d081a7
d40b7d4
d2e64c6
6967dd4
 
99b345f
 
 
 
d2e64c6
6967dd4
 
 
99b345f
6967dd4
 
f1bfa64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import gradio as gr
import openai
import pandas as pd
import plotly.express as px


# Load your CSV file
data = pd.read_csv("RR.csv")

# Set your OpenAI API key
openai.api_key = "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"



def query_gpt(prompt):
    model_engine = "text-davinci-002"  # Use any available GPT model here
    max_tokens = 50

    response = openai.Completion.create(
        engine=model_engine,
        prompt=prompt,
        max_tokens=max_tokens,
        n=1,
        stop=None,
        temperature=0.7,
    )

    message = response.choices[0].text.strip()
    return message


def get_insights(question):
    prompt = f"Please answer the question: {question}\n\nRemember, base your answer solely on the data provided in the dataset."
    answer = query_gpt(prompt)
    return answer


markdown_data = "Mock Dataset Sales & Marketing Budget"

iface = gr.Interface(
    fn=get_insights,
    inputs=[
        gr.inputs.Textbox(lines=2, label="Enter your question"),
    ],

    title="GPT-powered Q&A",
    description=markdown_data,
    examples=[
        "Are there any trends in sales forecast or actual sales?",
        "How does the marketing budget correlate with the sales actual?",
        "Can you identify any months with a significantly higher or lower number of support chats or calls compared to the overall average?",
        "Are there any patterns that suggest a need for additional staff during specific periods based on support chats and calls?",
    ],
    allow_screenshot=False,
    theme="compact",
    layout="vertical",
    article="",
)

iface.launch(inbrowser=True)