Spaces:
Paused
Paused
add Llama3-70b
Browse files- app.py +6 -2
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -6,6 +6,7 @@ import os
|
|
| 6 |
from langchain.chat_models import ChatOpenAI
|
| 7 |
from langchain.schema import HumanMessage, SystemMessage, AIMessage
|
| 8 |
from langchain_anthropic import ChatAnthropic, ChatAnthropicMessages
|
|
|
|
| 9 |
import openai
|
| 10 |
|
| 11 |
|
|
@@ -127,10 +128,13 @@ def generate(features, image, structure, reference, model, temperature):
|
|
| 127 |
print(f"Detected features: {detected_features}, Intended use: {intended_use}, Alt text: {alt_texts}")
|
| 128 |
if model.startswith("gpt"):
|
| 129 |
chat = ChatOpenAI(model=model)
|
| 130 |
-
|
| 131 |
chat = ChatAnthropic(model_name=model, anthropic_api_key=os.environ["ANTHROPIC_API_KEY"])
|
|
|
|
|
|
|
| 132 |
messages = [HumanMessage(content=f"""Write a product description of about 200 words for a product with the following key properties.
|
| 133 |
Make sure that the description follows the structure of the reference structure below.
|
|
|
|
| 134 |
Use creative language that is suitable for e-commerce websites. Use a consistent tone of voice throughout the text.
|
| 135 |
If the reference text is not empty, produce the product description in the tone of voice and structure of the reference text.
|
| 136 |
\n\n {features + detected_features} \n{intended_use} \nReference structure: {structure}\n Reference text: {reference}""")]
|
|
@@ -146,7 +150,7 @@ demo = gr.Interface(
|
|
| 146 |
gr.Gallery(label="Product image(s)", type="filepath"),
|
| 147 |
gr.Textbox(structure, label="Structure"),
|
| 148 |
gr.Textbox(reference, label="Reference copy"),
|
| 149 |
-
gr.Dropdown(["gpt-4-turbo", "gpt-3.5-turbo", "claude-3-sonnet-20240229", "claude-3-opus-20240229"], value="
|
| 150 |
gr.Slider(minimum=0., maximum=1.0, value=0.5, label="Temperature")],
|
| 151 |
outputs=["markdown"],
|
| 152 |
)
|
|
|
|
| 6 |
from langchain.chat_models import ChatOpenAI
|
| 7 |
from langchain.schema import HumanMessage, SystemMessage, AIMessage
|
| 8 |
from langchain_anthropic import ChatAnthropic, ChatAnthropicMessages
|
| 9 |
+
from langchain_groq import ChatGroq
|
| 10 |
import openai
|
| 11 |
|
| 12 |
|
|
|
|
| 128 |
print(f"Detected features: {detected_features}, Intended use: {intended_use}, Alt text: {alt_texts}")
|
| 129 |
if model.startswith("gpt"):
|
| 130 |
chat = ChatOpenAI(model=model)
|
| 131 |
+
elif model.startswith("claude"):
|
| 132 |
chat = ChatAnthropic(model_name=model, anthropic_api_key=os.environ["ANTHROPIC_API_KEY"])
|
| 133 |
+
else:
|
| 134 |
+
chat = ChatGroq(model_name=model, api_key=os.environ["GROQ_API_KEY"])
|
| 135 |
messages = [HumanMessage(content=f"""Write a product description of about 200 words for a product with the following key properties.
|
| 136 |
Make sure that the description follows the structure of the reference structure below.
|
| 137 |
+
Make sure to use markdown format for the output.
|
| 138 |
Use creative language that is suitable for e-commerce websites. Use a consistent tone of voice throughout the text.
|
| 139 |
If the reference text is not empty, produce the product description in the tone of voice and structure of the reference text.
|
| 140 |
\n\n {features + detected_features} \n{intended_use} \nReference structure: {structure}\n Reference text: {reference}""")]
|
|
|
|
| 150 |
gr.Gallery(label="Product image(s)", type="filepath"),
|
| 151 |
gr.Textbox(structure, label="Structure"),
|
| 152 |
gr.Textbox(reference, label="Reference copy"),
|
| 153 |
+
gr.Dropdown(["gpt-4-turbo", "gpt-3.5-turbo", "claude-3-sonnet-20240229", "claude-3-opus-20240229", "llama3-70b-8192"], value="llama3-70b-8192", label="Model"),
|
| 154 |
gr.Slider(minimum=0., maximum=1.0, value=0.5, label="Temperature")],
|
| 155 |
outputs=["markdown"],
|
| 156 |
)
|
requirements.txt
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
langchain
|
| 2 |
langchain_openai
|
| 3 |
langchain_anthropic
|
| 4 |
-
openai
|
|
|
|
|
|
| 1 |
langchain
|
| 2 |
langchain_openai
|
| 3 |
langchain_anthropic
|
| 4 |
+
openai
|
| 5 |
+
langchain_groq
|