fury-bot / main.py
robinroy03's picture
migrated to groq -- suuuuuper fast!
17aa59f
raw
history blame
865 Bytes
from flask import Flask
from flask import request
from groq import Groq
import os
app = Flask(__name__)
client = Groq(
api_key=os.environ.get("GROQ_API_KEY")
)
@app.route("/api/generate", methods=['POST'])
def completion():
"""
{
"model": "llama3-70b-8192",
"prompt": "why is the sky blue?"
}
"""
message = request.get_json()
model = message['model']
prompt = message['prompt']
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": prompt,
}
],
model=model,
)
return chat_completion.choices[0].message.content
# curl -v -X POST 'http://127.0.0.1:8000/api/generate' --header 'Content-Type: application/json' --data '{"model": "llama3-70b-8192", "prompt": "why is sky blue?"}'