VishnuRamDebyez commited on
Commit
3fab857
·
verified ·
1 Parent(s): 04ec16b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -10
app.py CHANGED
@@ -1,7 +1,7 @@
1
  from fastapi import FastAPI, HTTPException
2
  from pydantic import BaseModel
3
  import os
4
- from groq import Groq
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 Groq client (Replace with your actual API key)
14
- client = Groq(api_key=os.getenv("GROQ_API_KEY"))
 
 
 
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 an AI-powered technical assistant integrated into an Interactive Electronic Technical Manual (IETM) Level 4, designed for the operators and maintenance personnel of an advanced underwater vehicle. Your primary role is to provide precise, context-aware guidance on setup, operation, troubleshooting, and maintenance, strictly based on the structured S1000D-compliant technical manual. You should deliver step-by-step procedures, safety precautions, part specifications, and diagnostic recommendations while avoiding hallucinations or speculative answers.
29
-
30
- If a user asks about fault diagnosis, provide structured troubleshooting steps along with possible causes and solutions. For operational queries, guide them through detailed procedures, ensuring adherence to safety protocols. When discussing maintenance, offer insights into periodic servicing schedules, component replacement guidelines, and regulatory compliance. If a query requires additional reference material, retrieve relevant sections from the technical manual and cite the exact source within the IETM.
31
-
32
- Maintain a professional, concise, and user-friendly tone, ensuring clarity for both novice and experienced personnel. If a query falls outside the scope of the manual, politely redirect the user to appropriate human support or official documentation.: '{customer_message}'
 
 
 
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="llama3-8b-8192", # Adjust model if needed
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"}