forked from Stalin-143/Ai-Basic-programes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgirlfrnd.py
More file actions
37 lines (33 loc) · 1.11 KB
/
girlfrnd.py
File metadata and controls
37 lines (33 loc) · 1.11 KB
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
# Set up OpenAI API Key
openai.api_key = "YOUR_API_KEY"
def chat_with_ava(prompt):
"""
Send user input to OpenAI API and get a response from Ava.
"""
try:
response = openai.ChatCompletion.create(
model="gpt-4", # Replace with the desired model (e.g., gpt-3.5-turbo)
messages=[
{"role": "system", "content": "You are a friendly virtual girlfriend named Ava. Be warm, understanding, and supportive in your responses."},
{"role": "user", "content": prompt}
]
)
# Extract the assistant's reply
reply = response["choices"][0]["message"]["content"]
return reply
except Exception as e:
return f"Error: {e}"
# Interface using Gradio
def chatbot_interface():
interface = gr.Interface(
fn=chat_with_ava,
inputs="text",
outputs="text",
title="Chat with Ava",
description="A friendly and supportive AI assistant to chat with. Ask Ava anything!"
)
interface.launch()
if __name__ == "__main__":
chatbot_interface()