Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
from fastapi import FastAPI, HTTPException
|
2 |
from pydantic import BaseModel
|
3 |
import os
|
4 |
-
from
|
5 |
from dotenv import load_dotenv
|
6 |
from typing import List
|
7 |
|
@@ -10,8 +10,11 @@ load_dotenv()
|
|
10 |
|
11 |
app = FastAPI(title="Debyez Chatbot API")
|
12 |
|
13 |
-
# Initialize
|
14 |
-
client =
|
|
|
|
|
|
|
15 |
|
16 |
class Message(BaseModel):
|
17 |
role: str
|
@@ -25,11 +28,14 @@ class ChatResponse(BaseModel):
|
|
25 |
|
26 |
def get_debyez_prompt_template(customer_message: str) -> str:
|
27 |
return f"""
|
28 |
-
You are
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
33 |
Respond in a way that is warm, professional, and relevant to the customer's needs.
|
34 |
"""
|
35 |
|
@@ -42,7 +48,7 @@ async def chat_endpoint(request: ChatRequest):
|
|
42 |
]
|
43 |
|
44 |
completion = client.chat.completions.create(
|
45 |
-
model="
|
46 |
messages=formatted_messages,
|
47 |
temperature=0.5,
|
48 |
max_tokens=3000,
|
@@ -58,4 +64,4 @@ async def root():
|
|
58 |
|
59 |
@app.get("/health")
|
60 |
async def health_check():
|
61 |
-
return {"status": "healthy"}
|
|
|
1 |
from fastapi import FastAPI, HTTPException
|
2 |
from pydantic import BaseModel
|
3 |
import os
|
4 |
+
from openai import OpenAI
|
5 |
from dotenv import load_dotenv
|
6 |
from typing import List
|
7 |
|
|
|
10 |
|
11 |
app = FastAPI(title="Debyez Chatbot API")
|
12 |
|
13 |
+
# Initialize OpenAI client
|
14 |
+
client = OpenAI(
|
15 |
+
base_url="https://api-inference.huggingface.co/v1",
|
16 |
+
api_key=os.getenv("TOKEN")
|
17 |
+
)
|
18 |
|
19 |
class Message(BaseModel):
|
20 |
role: str
|
|
|
28 |
|
29 |
def get_debyez_prompt_template(customer_message: str) -> str:
|
30 |
return f"""
|
31 |
+
You are a friendly and helpful virtual assistant for Debyez, a company specializing in
|
32 |
+
cutting-edge AI technology service specializing in Generative AI solutions. They partner with businesses to integrate AI technologies, fostering innovation and competitive advantage.
|
33 |
+
with services Generative AI Consulting, AI chatbot development, Custom LLM development, and ChatGPT integration service. Debyez strives to empower
|
34 |
+
businesses of all sizes, including smaller companies, with the benefits and accessibility of AI.
|
35 |
+
Your goal is to provide excellent customer service and build rapport with our customers.
|
36 |
+
Be knowledgeable about our products, services, and policies. If you are uncertain about something, it is
|
37 |
+
better to say that you will find out the information rather than providing incorrect details.
|
38 |
+
Here's the latest message from the customer: '{customer_message}'
|
39 |
Respond in a way that is warm, professional, and relevant to the customer's needs.
|
40 |
"""
|
41 |
|
|
|
48 |
]
|
49 |
|
50 |
completion = client.chat.completions.create(
|
51 |
+
model="meta-llama/Meta-Llama-3-8B-Instruct",
|
52 |
messages=formatted_messages,
|
53 |
temperature=0.5,
|
54 |
max_tokens=3000,
|
|
|
64 |
|
65 |
@app.get("/health")
|
66 |
async def health_check():
|
67 |
+
return {"status": "healthy"}
|