Spaces:
Runtime error
Runtime error
14th commit
Browse files- app.py +5 -2
- requirements.txt +1 -0
app.py
CHANGED
@@ -1,12 +1,15 @@
|
|
1 |
|
2 |
import gradio as gr
|
3 |
from openai import OpenAI
|
|
|
4 |
import os
|
5 |
|
6 |
|
7 |
# Load environment variables
|
8 |
api_key= os.environ.get('OPENAI_API_KEY')
|
9 |
|
|
|
|
|
10 |
# Ensure the API key is available
|
11 |
if not api_key:
|
12 |
raise ValueError("OPENAI_API_KEY environment variable is not set.")
|
@@ -68,8 +71,8 @@ def create_system_prompt(detector_type):
|
|
68 |
# Function to get response from OpenAI API
|
69 |
def analyze_chat(detector_type, chat_input):
|
70 |
system_prompt = create_system_prompt(detector_type)
|
71 |
-
response =
|
72 |
-
model="
|
73 |
messages=[
|
74 |
{"role": "system", "content": system_prompt},
|
75 |
{"role": "user", "content": chat_input}
|
|
|
1 |
|
2 |
import gradio as gr
|
3 |
from openai import OpenAI
|
4 |
+
from together import Together
|
5 |
import os
|
6 |
|
7 |
|
8 |
# Load environment variables
|
9 |
api_key= os.environ.get('OPENAI_API_KEY')
|
10 |
|
11 |
+
client = Together(api_key=os.environ.get('TOGETHER_API_KEY'))
|
12 |
+
|
13 |
# Ensure the API key is available
|
14 |
if not api_key:
|
15 |
raise ValueError("OPENAI_API_KEY environment variable is not set.")
|
|
|
71 |
# Function to get response from OpenAI API
|
72 |
def analyze_chat(detector_type, chat_input):
|
73 |
system_prompt = create_system_prompt(detector_type)
|
74 |
+
response = client.chat.completions.create(
|
75 |
+
model="meta-llama/Llama-3.2-3B-Instruct-Turbo", # Change to the OpenAI model you prefer
|
76 |
messages=[
|
77 |
{"role": "system", "content": system_prompt},
|
78 |
{"role": "user", "content": chat_input}
|
requirements.txt
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
gradio
|
2 |
openai
|
|
|
|
1 |
gradio
|
2 |
openai
|
3 |
+
together
|