Spaces:
Sleeping
Sleeping
modify the application file
Browse files- requirements.txt +2 -1
- song-insight-app.py +4 -2
requirements.txt
CHANGED
@@ -3,4 +3,5 @@ langchain==0.1.12
|
|
3 |
wikipedia==1.4.0
|
4 |
openai==1.14.1
|
5 |
transformers==4.38.2
|
6 |
-
torch==2.2.1
|
|
|
|
3 |
wikipedia==1.4.0
|
4 |
openai==1.14.1
|
5 |
transformers==4.38.2
|
6 |
+
torch==2.2.1
|
7 |
+
langchain_google_genai==0.0.11
|
song-insight-app.py
CHANGED
@@ -4,6 +4,7 @@ from langchain.chat_models import ChatOpenAI
|
|
4 |
from langchain.chains import LLMChain
|
5 |
from langchain_community.retrievers import WikipediaRetriever
|
6 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
|
|
7 |
import os
|
8 |
|
9 |
|
@@ -16,7 +17,8 @@ def song_insight(song, artist):
|
|
16 |
docs = retriever.get_relevant_documents(query=query_input)
|
17 |
|
18 |
# LLM model
|
19 |
-
llm = ChatOpenAI(openai_api_key=os.environ['OPENAI_API_KEY'], model_name="gpt-3.5-turbo", temperature=0)
|
|
|
20 |
|
21 |
# Emotion Classifier Model
|
22 |
tokenizer = AutoTokenizer.from_pretrained("yangswei/emotion_text_classification")
|
@@ -65,6 +67,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
65 |
output_song_theme = gr.Label(num_top_classes=6, label="Theme")
|
66 |
gr.Interface(fn=song_insight, inputs=[song, artist], outputs=[output_song_meaning, output_song_theme])
|
67 |
example = gr.Examples([['Maroon', 'Taylor Swift'], ['Devil In Her Heart', 'The Beatles'],
|
68 |
-
['
|
69 |
|
70 |
demo.launch()
|
|
|
4 |
from langchain.chains import LLMChain
|
5 |
from langchain_community.retrievers import WikipediaRetriever
|
6 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
7 |
+
from langchain_google_genai import ChatGoogleGenerativeAI
|
8 |
import os
|
9 |
|
10 |
|
|
|
17 |
docs = retriever.get_relevant_documents(query=query_input)
|
18 |
|
19 |
# LLM model
|
20 |
+
# llm = ChatOpenAI(openai_api_key=os.environ['OPENAI_API_KEY'], model_name="gpt-3.5-turbo", temperature=0)
|
21 |
+
llm = ChatGoogleGenerativeAI(model="gemini-pro", google_api_key=os.environ['GOOGLE_API_KEY'])
|
22 |
|
23 |
# Emotion Classifier Model
|
24 |
tokenizer = AutoTokenizer.from_pretrained("yangswei/emotion_text_classification")
|
|
|
67 |
output_song_theme = gr.Label(num_top_classes=6, label="Theme")
|
68 |
gr.Interface(fn=song_insight, inputs=[song, artist], outputs=[output_song_meaning, output_song_theme])
|
69 |
example = gr.Examples([['Maroon', 'Taylor Swift'], ['Devil In Her Heart', 'The Beatles'],
|
70 |
+
['Bedtime Stories', 'Jay Chou'], ['Loser', 'BIGBANG']], [song, artist])
|
71 |
|
72 |
demo.launch()
|