Spaces:
Paused
Paused
add gpt-4o
Browse files
app.py
CHANGED
|
@@ -55,6 +55,7 @@ languages = ["American English",
|
|
| 55 |
"Portuguese"]
|
| 56 |
|
| 57 |
models = ["gpt-4-turbo",
|
|
|
|
| 58 |
"gpt-3.5-turbo",
|
| 59 |
"claude-3-sonnet-20240229",
|
| 60 |
"claude-3-opus-20240229",
|
|
@@ -105,7 +106,7 @@ def detect_features(image_paths, garment_type, language="English"):
|
|
| 105 |
}
|
| 106 |
|
| 107 |
payload = {
|
| 108 |
-
"model": "gpt-
|
| 109 |
"messages": [
|
| 110 |
{
|
| 111 |
"role": "user",
|
|
@@ -138,6 +139,8 @@ def detect_features(image_paths, garment_type, language="English"):
|
|
| 138 |
|
| 139 |
response = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, json=payload)
|
| 140 |
|
|
|
|
|
|
|
| 141 |
response = response.json()
|
| 142 |
print("image features", response["choices"][0]['message']['content'])
|
| 143 |
jresponse = get_json(response["choices"][0]['message']['content'])
|
|
@@ -150,6 +153,7 @@ def detect_features(image_paths, garment_type, language="English"):
|
|
| 150 |
|
| 151 |
def generate(*data):
|
| 152 |
global visible
|
|
|
|
| 153 |
|
| 154 |
feature, image, garment_type, model, temperature = data[:5]
|
| 155 |
struct_ref = data[5:]
|
|
@@ -179,7 +183,7 @@ def generate(*data):
|
|
| 179 |
messages = [
|
| 180 |
SystemMessage(content=f"""You are a helpful assistant that writes about products for ecommerce websites."""),
|
| 181 |
HumanMessage(content=f"""Write a product description with the following features.
|
| 182 |
-
Make sure that the description follows the structure of the reference structure.
|
| 183 |
Make sure to use markdown format for the output.
|
| 184 |
Make sure that the entire output is written entirely in language defined in the reference structure.
|
| 185 |
Use language that is suitable for the type of document specified in the reference structure.
|
|
@@ -256,6 +260,5 @@ with gr.Blocks() as demo:
|
|
| 256 |
advanced.click(show_advanced, inputs=[], outputs=[model, temperature])
|
| 257 |
|
| 258 |
|
| 259 |
-
|
| 260 |
if __name__ == '__main__':
|
| 261 |
demo.launch()
|
|
|
|
| 55 |
"Portuguese"]
|
| 56 |
|
| 57 |
models = ["gpt-4-turbo",
|
| 58 |
+
"gpt-4o",
|
| 59 |
"gpt-3.5-turbo",
|
| 60 |
"claude-3-sonnet-20240229",
|
| 61 |
"claude-3-opus-20240229",
|
|
|
|
| 106 |
}
|
| 107 |
|
| 108 |
payload = {
|
| 109 |
+
"model": "gpt-4o",
|
| 110 |
"messages": [
|
| 111 |
{
|
| 112 |
"role": "user",
|
|
|
|
| 139 |
|
| 140 |
response = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, json=payload)
|
| 141 |
|
| 142 |
+
print(response)
|
| 143 |
+
|
| 144 |
response = response.json()
|
| 145 |
print("image features", response["choices"][0]['message']['content'])
|
| 146 |
jresponse = get_json(response["choices"][0]['message']['content'])
|
|
|
|
| 153 |
|
| 154 |
def generate(*data):
|
| 155 |
global visible
|
| 156 |
+
print("visible", visible)
|
| 157 |
|
| 158 |
feature, image, garment_type, model, temperature = data[:5]
|
| 159 |
struct_ref = data[5:]
|
|
|
|
| 183 |
messages = [
|
| 184 |
SystemMessage(content=f"""You are a helpful assistant that writes about products for ecommerce websites."""),
|
| 185 |
HumanMessage(content=f"""Write a product description with the following features.
|
| 186 |
+
Make sure that the description follows the structure of the reference structure. The first line in the reference structure include the document type and the language code. The next lines define the structure of the document to be generated.
|
| 187 |
Make sure to use markdown format for the output.
|
| 188 |
Make sure that the entire output is written entirely in language defined in the reference structure.
|
| 189 |
Use language that is suitable for the type of document specified in the reference structure.
|
|
|
|
| 260 |
advanced.click(show_advanced, inputs=[], outputs=[model, temperature])
|
| 261 |
|
| 262 |
|
|
|
|
| 263 |
if __name__ == '__main__':
|
| 264 |
demo.launch()
|