File size: 1,098 Bytes
3eed6e5
 
 
 
929859d
3eed6e5
 
 
 
929859d
3eed6e5
 
 
 
 
 
929859d
11c687a
3eed6e5
 
80105e8
929859d
 
3eed6e5
 
929859d
 
 
3eed6e5
 
 
 
 
929859d
 
 
3eed6e5
929859d
 
3eed6e5
 
 
e973c3a
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
import gradio as gr
import openai

DESCRIPTION = """
Hãy để trợ lý của AI Consultant hỗ trợ bạn !
"""

# Define inputs and outputs
inputs = [
    gr.inputs.Textbox(label="Câu hỏi:"),
]

outputs = [
    gr.outputs.Textbox(label="Câu trả lời:")
]

def chatbot(input):
    openai.api_key = "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"
    
    response = openai.Completion.create(
        engine="text-davinci-002",
        prompt=input,
        max_tokens=100
    )
    
    return response.choices[0].text.strip()

# Create a Gradio interface with title, logo, and caption

interface = gr.Interface(
    fn=chatbot,
    inputs=inputs,
    outputs=outputs,
    title="AI Consultant",  # Add the title here
    theme="compact",  # You can adjust the theme as needed
    layout="vertical",  # You can adjust the layout as needed
    allow_flagging="never",
    live=False,  # Set live to False to display the title, logo, and caption immediately
    description=DESCRIPTION,  # Update the description here
    css='style.css'
)
# Launch the interface
interface.launch()