llm-test / app.py
krammnic's picture
Update app.py
552e624 verified
raw
history blame
735 Bytes
from typing import Union
from fastapi import FastAPI
import asyncio
from groq import Groq, AsyncGroq
client = AsyncGroq(
api_key="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",
)
SYSTEM_PROMPT = """
You are helpful assistant, your task is to help me operating my system!
"""
app = FastAPI()
@app.post("/get_response")
async def read_root(messages: list[dict]):
messages.insert(0, {
"role": "system",
"content": SYSTEM_PROMPT
}
)
chat_completion = await client.chat.completions.create(
messages=messages,
model="llama3-70b-8192",
)
return chat_completion.choices[0].message.content
@app.get("/test")
async def read_root():
return "hello"