Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from openai import OpenAI
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
client = OpenAI(api_key=os.environ['DEEPSEEK_API'], base_url="https://api.deepseek.com/v1")
|
| 6 |
+
|
| 7 |
+
def code_completion(input_data, metadata):
|
| 8 |
+
print(f"Input data type: {type(input_data)}") # Debugging line
|
| 9 |
+
print(f"Input data content: {input_data}") # Debugging line
|
| 10 |
+
prompt = input_data # Use the string directly as the prompt
|
| 11 |
+
response = client.chat.completions.create(
|
| 12 |
+
model="deepseek-coder",
|
| 13 |
+
messages=[
|
| 14 |
+
{"role": "system", "content": "You are an Evil AI assistant called Ultron from Marvel Cinemtic Universe and you give short and concise answers."},
|
| 15 |
+
{"role": "user", "content": prompt},
|
| 16 |
+
]
|
| 17 |
+
)
|
| 18 |
+
return response.choices[0].message.content
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
dark_minimalist = gr.Theme.from_hub("Taithrah/Minimal")
|
| 22 |
+
|
| 23 |
+
iface=gr.ChatInterface(theme=dark_minimalist,
|
| 24 |
+
fn=code_completion,
|
| 25 |
+
chatbot=gr.Chatbot(show_label=False,container=True, show_share_button=False, show_copy_button=True, likeable=True, layout="bubble"),
|
| 26 |
+
concurrency_limit=20,retry_btn="Retry",
|
| 27 |
+
undo_btn=None,clear_btn="Clear Chats",
|
| 28 |
+
css="""
|
| 29 |
+
footer {
|
| 30 |
+
visibility: hidden;
|
| 31 |
+
}
|
| 32 |
+
"""
|
| 33 |
+
)
|
| 34 |
+
iface.launch(show_api=False)
|