File size: 958 Bytes
ca39e63
 
 
 
 
 
 
 
 
 
 
 
 
 
5e2d4bd
 
 
ca39e63
f5be4ec
6c12150
a08971c
8dc9124
7e320e1
 
aadd71e
732ee73
 
ca39e63
be32b79
70117e2
aadd71e
70117e2
ca39e63
 
8dc9124
c7c1b41
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
import openai
import gradio as gr

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

# Load text from file
with open("Dropsheets.txt", "r") as f:
    text = f.read()

# Define OpenAI GPT-3.5 model function
def generate_text(prompt):
    response = openai.Completion.create(
        engine="text-davinci-002",
        temperature=0,
        max_tokens=1024,
        prompt=prompt
    )
    return response.choices[0].text.strip()      

    
# Create Gradio interface
input_text = gr.Textbox(label="Enter prompt", type="text")
output_text = gr.Textbox(label="AI response", type="text")
demo = gr.Interface(
    fn = generate_text,
    inputs=input_text,
    outputs=output_text,
    title="AI Chatbot for PlanetTogether Knowledge Base",
    description="Ask a question about the PlanetTogether APS:",
    examples=[["How do you create an Alternate Path?"]],
    theme="default"
)

# Launch demo
demo.launch()