VishnuRamDebyez commited on
Commit
cfed78a
·
verified ·
1 Parent(s): cd67ad3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -3,7 +3,7 @@ from pydantic import BaseModel
3
  import os
4
  from openai import OpenAI
5
  from dotenv import load_dotenv
6
- from typing import List, Optional
7
 
8
  # Load environment variables
9
  load_dotenv()
@@ -42,13 +42,11 @@ def get_debyez_prompt_template(customer_message: str) -> str:
42
  @app.post("/chat", response_model=ChatResponse)
43
  async def chat_endpoint(request: ChatRequest):
44
  try:
45
- # Process messages with the template
46
  formatted_messages = [
47
  {"role": msg.role, "content": get_debyez_prompt_template(msg.content)}
48
  for msg in request.messages
49
  ]
50
 
51
- # Create chat completion
52
  completion = client.chat.completions.create(
53
  model="meta-llama/Meta-Llama-3-8B-Instruct",
54
  messages=formatted_messages,
@@ -60,6 +58,10 @@ async def chat_endpoint(request: ChatRequest):
60
  except Exception as e:
61
  raise HTTPException(status_code=500, detail=str(e))
62
 
 
 
 
 
63
  @app.get("/health")
64
  async def health_check():
65
  return {"status": "healthy"}
 
3
  import os
4
  from openai import OpenAI
5
  from dotenv import load_dotenv
6
+ from typing import List
7
 
8
  # Load environment variables
9
  load_dotenv()
 
42
  @app.post("/chat", response_model=ChatResponse)
43
  async def chat_endpoint(request: ChatRequest):
44
  try:
 
45
  formatted_messages = [
46
  {"role": msg.role, "content": get_debyez_prompt_template(msg.content)}
47
  for msg in request.messages
48
  ]
49
 
 
50
  completion = client.chat.completions.create(
51
  model="meta-llama/Meta-Llama-3-8B-Instruct",
52
  messages=formatted_messages,
 
58
  except Exception as e:
59
  raise HTTPException(status_code=500, detail=str(e))
60
 
61
+ @app.get("/")
62
+ async def root():
63
+ return {"message": "Welcome to Debyez Chatbot API"}
64
+
65
  @app.get("/health")
66
  async def health_check():
67
  return {"status": "healthy"}