Spaces:
Running
Running
Patch cost formatting to a fixed decimal format with trailing zeros
Browse files
app.py
CHANGED
@@ -53,7 +53,15 @@ def predict(
|
|
53 |
if 'choices' in json_response and len(json_response['choices']) > 0:
|
54 |
assistant_content = json_response['choices'][0]['message']['content']
|
55 |
chat_history.append({"role": "assistant", "content": assistant_content})
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
else:
|
58 |
chat_history.append({"role": "assistant", "content": "Error: No response from assistant."})
|
59 |
|
@@ -64,17 +72,27 @@ def predict(
|
|
64 |
return chat_history, "*Generation error..*"
|
65 |
|
66 |
css = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
.gradio-container {
|
68 |
-
height: 100vh;
|
69 |
display: flex;
|
70 |
flex-direction: column;
|
|
|
|
|
|
|
|
|
71 |
}
|
72 |
|
73 |
-
.api-panel {
|
74 |
-
display: none !important;
|
75 |
-
}
|
76 |
-
|
77 |
-
footer {
|
78 |
display: none !important;
|
79 |
}
|
80 |
|
@@ -109,6 +127,8 @@ footer {
|
|
109 |
margin-bottom: 2rem;
|
110 |
color: #ffffff;
|
111 |
border: 1px solid #333;
|
|
|
|
|
112 |
}
|
113 |
|
114 |
.warning-title {
|
@@ -232,5 +252,5 @@ if __name__ == "__main__":
|
|
232 |
demo.launch(
|
233 |
server_name="0.0.0.0",
|
234 |
server_port=7860,
|
235 |
-
share=
|
236 |
)
|
|
|
53 |
if 'choices' in json_response and len(json_response['choices']) > 0:
|
54 |
assistant_content = json_response['choices'][0]['message']['content']
|
55 |
chat_history.append({"role": "assistant", "content": assistant_content})
|
56 |
+
total_cost = json_response["usage"]["cost"]["total"]
|
57 |
+
formatted_cost = f"{total_cost:.10f}"
|
58 |
+
|
59 |
+
stats_content = (
|
60 |
+
f'*Powered by Oxygen, '
|
61 |
+
f'Generation time: {json_response["usage"]["metrics"]["inference_time_ms"]} ms, '
|
62 |
+
f'Tokens per second: {json_response["usage"]["metrics"]["tokens_per_second"]}, '
|
63 |
+
f'Generation cost: {formatted_cost} EUR*'
|
64 |
+
)
|
65 |
else:
|
66 |
chat_history.append({"role": "assistant", "content": "Error: No response from assistant."})
|
67 |
|
|
|
72 |
return chat_history, "*Generation error..*"
|
73 |
|
74 |
css = """
|
75 |
+
html, body {
|
76 |
+
margin: 0;
|
77 |
+
padding: 0;
|
78 |
+
height: 100%;
|
79 |
+
background: #1a1a1a;
|
80 |
+
color: #ffffff;
|
81 |
+
font-family: 'Inter', ui-sans-serif, system-ui;
|
82 |
+
-webkit-font-smoothing: antialiased;
|
83 |
+
-moz-osx-font-smoothing: grayscale;
|
84 |
+
}
|
85 |
+
|
86 |
.gradio-container {
|
|
|
87 |
display: flex;
|
88 |
flex-direction: column;
|
89 |
+
height: 100vh;
|
90 |
+
background: #1a1a1a;
|
91 |
+
color: #ffffff;
|
92 |
+
overflow-y: auto;
|
93 |
}
|
94 |
|
95 |
+
footer, .api-panel {
|
|
|
|
|
|
|
|
|
96 |
display: none !important;
|
97 |
}
|
98 |
|
|
|
127 |
margin-bottom: 2rem;
|
128 |
color: #ffffff;
|
129 |
border: 1px solid #333;
|
130 |
+
max-height: 70vh;
|
131 |
+
overflow-y: auto;
|
132 |
}
|
133 |
|
134 |
.warning-title {
|
|
|
252 |
demo.launch(
|
253 |
server_name="0.0.0.0",
|
254 |
server_port=7860,
|
255 |
+
share=False
|
256 |
)
|