Spaces:
Sleeping
Sleeping
File size: 1,172 Bytes
762b248 3d3cb20 762b248 0366195 454c0a1 0366195 4b39287 454c0a1 762b248 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
import streamlit as st
import os
import pandas as pd
os.system("pip install together")
from together import Together
import os
# Set the environment variable (just for testing purposes)
os.environ["api"] = "tgp_v1_QxHjcs582Y4kSGPd5a2VyrKDD6S81ctp-M-rT_ioDNE"
# 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 |