Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,23 @@
|
|
1 |
"""SusAI ©2025 Intern Labs. v1.1.0"""
|
2 |
import os
|
3 |
import gradio as gr
|
4 |
-
|
5 |
from gradio_client import Client
|
6 |
|
7 |
# Initialize Hugging Face Inference Client
|
8 |
-
client = Client("HydroFlyer53/ThePickle", hf_token=os.environ
|
9 |
|
10 |
def chat_with_ai(message, history):
|
11 |
-
"""Function to get AI response from Hugging Face model."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
result = client.predict(
|
14 |
-
message=
|
15 |
system_message=(
|
16 |
"You are an AI that talks in Gen-Z slang, and also says things like skibbidy and sigma, "
|
17 |
"but aren't really that smart or helpful. If you are asked to stop talking in slang, "
|
@@ -24,10 +30,11 @@ def chat_with_ai(message, history):
|
|
24 |
top_p=0.60,
|
25 |
api_name="/chat"
|
26 |
)
|
|
|
27 |
return result
|
28 |
|
29 |
-
# Gradio Chat Interface
|
30 |
demo = gr.ChatInterface(fn=chat_with_ai)
|
31 |
|
32 |
if __name__ == "__main__":
|
33 |
-
demo.launch()
|
|
|
1 |
"""SusAI ©2025 Intern Labs. v1.1.0"""
|
2 |
import os
|
3 |
import gradio as gr
|
|
|
4 |
from gradio_client import Client
|
5 |
|
6 |
# Initialize Hugging Face Inference Client
|
7 |
+
client = Client("HydroFlyer53/ThePickle", hf_token=os.environ["Key"])
|
8 |
|
9 |
def chat_with_ai(message, history):
|
10 |
+
"""Function to get AI response from Hugging Face model with limited history tracking."""
|
11 |
+
|
12 |
+
# Retain only the last 3 exchanges in history
|
13 |
+
trimmed_history = history[-3:] if history else []
|
14 |
+
formatted_history = "\n".join([f"User: {h[0]}\nAI: {h[1]}" for h in trimmed_history])
|
15 |
+
|
16 |
+
# Combine history with new message
|
17 |
+
prompt = f"{formatted_history}\nUser: {message}\nAI:"
|
18 |
|
19 |
result = client.predict(
|
20 |
+
message=prompt,
|
21 |
system_message=(
|
22 |
"You are an AI that talks in Gen-Z slang, and also says things like skibbidy and sigma, "
|
23 |
"but aren't really that smart or helpful. If you are asked to stop talking in slang, "
|
|
|
30 |
top_p=0.60,
|
31 |
api_name="/chat"
|
32 |
)
|
33 |
+
|
34 |
return result
|
35 |
|
36 |
+
# Gradio Chat Interface with history
|
37 |
demo = gr.ChatInterface(fn=chat_with_ai)
|
38 |
|
39 |
if __name__ == "__main__":
|
40 |
+
demo.launch()
|