Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import base64
|
| 2 |
+
import os
|
| 3 |
+
from google import genai
|
| 4 |
+
from google.genai import types
|
| 5 |
+
import streamlit as st
|
| 6 |
+
|
| 7 |
+
def generate():
|
| 8 |
+
client = genai.Client(
|
| 9 |
+
api_key=os.environ.get("AIzaSyBDfb85vueYjLTGvArrgBsAYF4d8u6LfuU"),
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
model = "gemini-2.5-pro-exp-03-25"
|
| 13 |
+
contents = [
|
| 14 |
+
types.Content(
|
| 15 |
+
role="user",
|
| 16 |
+
parts=[
|
| 17 |
+
types.Part.from_text(text="""INSERT_INPUT_HERE"""),
|
| 18 |
+
],
|
| 19 |
+
),
|
| 20 |
+
]
|
| 21 |
+
generate_content_config = types.GenerateContentConfig(
|
| 22 |
+
temperature=1,
|
| 23 |
+
top_p=0.95,
|
| 24 |
+
top_k=64,
|
| 25 |
+
max_output_tokens=65536,
|
| 26 |
+
response_mime_type="text/plain",
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
for chunk in client.models.generate_content_stream(
|
| 30 |
+
model=model,
|
| 31 |
+
contents=contents,
|
| 32 |
+
config=generate_content_config,
|
| 33 |
+
):
|
| 34 |
+
print(chunk.text, end="")
|
| 35 |
+
|
| 36 |
+
if __name__ == "__main__":
|
| 37 |
+
generate()
|