|
|
|
from openai import OpenAI
|
|
import streamlit as st
|
|
|
|
|
|
client = OpenAI(api_key='2051e9263e2e4f0e9afb23afe4a654fa', base_url='https://api.aimlapi.com/')
|
|
|
|
|
|
system_prompt = (
|
|
'You are a helpful assistant that provides positive, optimistic, uplifting, '
|
|
'and motivational quotes filled with wisdom, encouragement, and hope to uplift and inspire people.'
|
|
)
|
|
|
|
def generate_positive_quote(feeling):
|
|
|
|
user_prompt = f'Give me a positive quote that can help someone who feels {feeling}.'
|
|
|
|
|
|
messages = [
|
|
{'role': 'system', 'content': system_prompt},
|
|
{'role': 'user', 'content': user_prompt}
|
|
]
|
|
|
|
|
|
response = client.chat.completions.create(
|
|
model="meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo",
|
|
messages=messages,
|
|
temperature=0.5,
|
|
max_tokens=100
|
|
)
|
|
|
|
|
|
return response.choices[0].message.content
|
|
|
|
|
|
|
|
|
|
st.title('✨ Positive Quote Generator ✨')
|
|
|
|
st.markdown("Welcome to the Positive Quote Generator! Click the button below to receive an uplifting message.")
|
|
|
|
feeling = st.text_input('How do you feel today?', '')
|
|
|
|
|
|
if st.button('Get Positive Quote'):
|
|
if feeling:
|
|
quote = generate_positive_quote(feeling)
|
|
st.success(quote)
|
|
else:
|
|
st.error('Please enter how you feel.')
|
|
|
|
|