Update app.py
Browse files
app.py
CHANGED
@@ -8,9 +8,9 @@ credentials = os.environ["CREDENTIALS"]
|
|
8 |
project = os.environ["PROJECT"]
|
9 |
wandb_api_key = os.environ["WANDB_API_KEY"]
|
10 |
|
11 |
-
config = {
|
12 |
-
"model": "text-bison@001",
|
13 |
-
}
|
14 |
|
15 |
wandb.login(key = wandb_api_key)
|
16 |
wandb.init(project = "vertex-ai-llm", config = config)
|
@@ -29,14 +29,18 @@ vertexai.init(project = project,
|
|
29 |
credentials = credentials
|
30 |
)
|
31 |
|
32 |
-
from vertexai.language_models import TextGenerationModel
|
33 |
-
generation_model = TextGenerationModel.from_pretrained(config.model)
|
|
|
|
|
|
|
34 |
|
35 |
def invoke(prompt):
|
36 |
#completion = generation_model.predict(prompt = prompt).text
|
37 |
-
|
38 |
-
|
39 |
-
return
|
|
|
40 |
|
41 |
description = """<a href='https://www.gradio.app/'>Gradio</a> UI using <a href='https://cloud.google.com/vertex-ai?hl=en/'>Google Vertex AI</a> API
|
42 |
with Bison foundation model. Model performance evaluation via <a href='https://wandb.ai/bstraehle'>Weights & Biases</a>."""
|
|
|
8 |
project = os.environ["PROJECT"]
|
9 |
wandb_api_key = os.environ["WANDB_API_KEY"]
|
10 |
|
11 |
+
#config = {
|
12 |
+
# "model": "text-bison@001",
|
13 |
+
#}
|
14 |
|
15 |
wandb.login(key = wandb_api_key)
|
16 |
wandb.init(project = "vertex-ai-llm", config = config)
|
|
|
29 |
credentials = credentials
|
30 |
)
|
31 |
|
32 |
+
#from vertexai.language_models import TextGenerationModel
|
33 |
+
#generation_model = TextGenerationModel.from_pretrained(config.model)
|
34 |
+
|
35 |
+
from vertexai.preview.generative_models import GenerativeModel
|
36 |
+
generation_model = GenerativeModel("gemini-pro")
|
37 |
|
38 |
def invoke(prompt):
|
39 |
#completion = generation_model.predict(prompt = prompt).text
|
40 |
+
completion = generation_model.generate_content(prompt = prompt).text
|
41 |
+
wandb.log({"prompt": prompt, "completion": completion})
|
42 |
+
return completion
|
43 |
+
#return "Execution is commented out, but you can view the code at https://huggingface.co/spaces/bstraehle/google-vertex-ai-llm/tree/main."
|
44 |
|
45 |
description = """<a href='https://www.gradio.app/'>Gradio</a> UI using <a href='https://cloud.google.com/vertex-ai?hl=en/'>Google Vertex AI</a> API
|
46 |
with Bison foundation model. Model performance evaluation via <a href='https://wandb.ai/bstraehle'>Weights & Biases</a>."""
|