Skip to content

Commit

Permalink
MODIFIED: stream chat endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
AquibPy committed Apr 28, 2024
1 parent 6868432 commit 5022d10
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions api.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ async def summarize_audio_endpoint(audio_file: UploadFile = File(...)):


@app.post("/stream_chat",description="This endpoint streams responses from the language model based on the user's input message.")
async def stream_chat(message: str = Form("What is RLHF in LLM?")):
generator = chatbot_send_message(message)
async def stream_chat(message: str = Form("What is RLHF in LLM?"),llm: str = Form("llama3-70b-8192")):
generator = chatbot_send_message(message,model=llm)
return StreamingResponse(generator, media_type="text/event-stream")

@app.post("/smart_ats",description="""This endpoint is developed using the powerful
Expand Down
4 changes: 2 additions & 2 deletions helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,12 @@ async def summarize_audio(audio_file):
return response.text


async def chatbot_send_message(content: str) -> AsyncIterable[str]:
async def chatbot_send_message(content: str,model: str) -> AsyncIterable[str]:
callback = AsyncIteratorCallbackHandler()
model = ChatGroq(
temperature=0,
groq_api_key=os.environ['GROQ_API_KEY'],
model_name="llama3-70b-8192",
model_name=model,
streaming=True,
verbose=True,
callbacks=[callback],
Expand Down
3 changes: 2 additions & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ <h1>Chat with LLAMA 3 🦙🦙🦙</h1>
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: 'message=' + encodeURIComponent(message)
body: 'message=' + encodeURIComponent(message),
'llm': 'llama3-70b-8192'
});
var reader = response.body.getReader();
var decoder = new TextDecoder('utf-8');
Expand Down

0 comments on commit 5022d10

Please sign in to comment.