Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| import pathlib | |
| import textwrap | |
| import requests | |
| import google.generativeai as genai | |
| import json | |
| import os | |
| # VIDEO_URL = "https://example.com/not-youtube.mp4" | |
| # st.video(VIDEO_URL) | |
| title = response.text | |
| # print(str(title)) | |
| # print(lyrics) | |
| # print(genre) | |
| st.set_page_config(page_title="NutriMentor", page_icon=":robot:") | |
| st.header("NutriMentor") | |
| if "generated" not in st.session_state: | |
| st.session_state["generated"] = [] | |
| if "past" not in st.session_state: | |
| st.session_state["past"] = [] | |
| if "messages" not in st.session_state: | |
| st.session_state["messages"] = [] | |
| init_alr = False | |
| def init_model(): | |
| os.environ["API_KEY"] = "AIzaSyCADQk7KaP90mSKslhtEC3qRjyeUVxBkvI" | |
| genai.configure(api_key=os.environ.get("API_KEY")) | |
| model = genai.GenerativeModel('gemini-pro') | |
| userInput = "Give me an afrofunk beat along with a cool melody and catchy drums, along with an opera style" | |
| prompt = userInput + ". Output ONLY the specific music genre that the user would like that fits their requirements, with no excess words. Simply the genre, NO APOSTROPHES. If required, add more than one genre to best fit the user's prompt by adding a comma and space and a another genre. Desired Output: <all_lowercase_comma_separated_genres>" | |
| response = model.generate_content(prompt) | |
| genre = response.text | |
| userInput = "Genre: " + genre + ". Generate lyrics that would best fit into the required genre. The lyrics should not be about the genre, but would best fit into the genre. Generate around 1 minutes worth of lyrics. Separate verses using [Verse #] and NO APOSTROPHES AT ALL. If you must use them, please remove them from the word, even if it mispells the word. Desired Format: <seperate_each_verse_no_asteriks_or_apostrophes>" | |
| response = model.generate_content(userInput) | |
| lyrics = response.text | |
| lyricInput = "Lyrics: " + lyrics + ". Based upon the following lyrics, please generate a title for this song. Desired Format: <title_case_without_genre>" | |
| response = model.generate_content(lyricInput) | |
| return genre | |
| st_callback = StreamlitCallbackHandler(st.container()) | |
| date_input = st.text_input(label = "Enter Date (ex. 10-11) ๐") | |
| if prompt := st.chat_input(): | |
| st.chat_message("user").write(prompt) | |
| with st.chat_message("assistant"): | |
| #st_callback = StreamlitCallbackHandler(st.container()) | |
| if init_alr == False: | |
| init_alr = True | |
| genre = init_model() | |
| #Call query generator with text_input | |
| #query = prompty(date_input, prompt) | |
| #result = qa({"query": query}) | |
| st.write(genre) | |
| st.video('modelscopet2v.mp4') | |
| st.stop() | |