Inara132000's picture
Update utils/helper.py
7592416 verified
import streamlit as st
import os
import pandas as pd
from together import Together
os.environ["api"] = "6bfaddf602548e0203eb5309a6649a0e2cc32b2a0705a4d962fe9bd0d06c4b0b"
# Now, the code can access the api key from the environment variable
client = Together(api_key=os.environ["api"])
def call_llama(prompt: str) -> str:
"""
Send a prompt to the Llama model and return the response.
Args:
prompt (str): The input prompt to send to the Llama model.
Returns:
str: The response from the Llama model.
"""
# Create a completion request with the prompt
response = client.chat.completions.create(
# Use the Llama-3-8b-chat-hf model
model="meta-llama/Llama-3-8b-chat-hf",
# Define the prompt as a user message
messages=[
{
"role": "user",
"content": prompt # Use the input prompt
}
],
temperature=0.7,
)
# Return the content of the first response message
return response.choices[0].message.content