Spaces:
Sleeping
Sleeping
Haoyuan Zhang
commited on
Commit
·
ee18950
1
Parent(s):
2823615
test genai
Browse files- main.py +8 -8
- requirements.txt +2 -1
main.py
CHANGED
|
@@ -6,15 +6,15 @@ import os
|
|
| 6 |
|
| 7 |
import mesop as me
|
| 8 |
import mesop.labs as mel
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
|
|
|
| 12 |
|
| 13 |
def on_load(e: me.LoadEvent):
|
| 14 |
me.set_theme_mode("system")
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
@me.page(
|
| 19 |
security_policy=me.SecurityPolicy(
|
| 20 |
allowed_iframe_parents=["https://huggingface.co"]
|
|
@@ -27,11 +27,11 @@ def page():
|
|
| 27 |
|
| 28 |
|
| 29 |
def transform(input: str, history: list[mel.ChatMessage]):
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
| 33 |
|
| 34 |
-
print(API_KEY)
|
| 35 |
|
| 36 |
LINES = [
|
| 37 |
"Mesop is a Python-based UI framework designed to simplify web UI development for engineers without frontend experience.",
|
|
|
|
| 6 |
|
| 7 |
import mesop as me
|
| 8 |
import mesop.labs as mel
|
| 9 |
+
import google.generativeai as genai
|
| 10 |
|
| 11 |
+
MY_API_KEY = os.getenv("API_KEY")
|
| 12 |
+
genai.configure(api_key=MY_API_KEY)
|
| 13 |
+
model = genai.GenerativeModel('models/gemini-2.0-flash')
|
| 14 |
|
| 15 |
def on_load(e: me.LoadEvent):
|
| 16 |
me.set_theme_mode("system")
|
| 17 |
|
|
|
|
|
|
|
| 18 |
@me.page(
|
| 19 |
security_policy=me.SecurityPolicy(
|
| 20 |
allowed_iframe_parents=["https://huggingface.co"]
|
|
|
|
| 27 |
|
| 28 |
|
| 29 |
def transform(input: str, history: list[mel.ChatMessage]):
|
| 30 |
+
model.generate_content(input)
|
| 31 |
+
# for line in random.sample(LINES, random.randint(3, len(LINES) - 1)):
|
| 32 |
+
# time.sleep(0.3)
|
| 33 |
+
# yield line + " "
|
| 34 |
|
|
|
|
| 35 |
|
| 36 |
LINES = [
|
| 37 |
"Mesop is a Python-based UI framework designed to simplify web UI development for engineers without frontend experience.",
|
requirements.txt
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
mesop
|
| 2 |
gunicorn
|
| 3 |
pandas
|
| 4 |
-
numpy
|
|
|
|
|
|
| 1 |
mesop
|
| 2 |
gunicorn
|
| 3 |
pandas
|
| 4 |
+
numpy
|
| 5 |
+
google-generativeai
|