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)