Update app.py
Browse files
app.py
CHANGED
@@ -17,9 +17,6 @@ config = {
|
|
17 |
"top_p": 1.0,
|
18 |
}
|
19 |
|
20 |
-
#wandb.login(key = wandb_api_key)
|
21 |
-
#wandb.init(project = "vertex-ai-llm", config = config)
|
22 |
-
|
23 |
credentials = json.loads(credentials)
|
24 |
|
25 |
from google.oauth2 import service_account
|
@@ -38,6 +35,12 @@ vertexai.init(project = project,
|
|
38 |
from vertexai.preview.generative_models import GenerativeModel
|
39 |
generation_model = GenerativeModel(config["model"])
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
def invoke(prompt):
|
42 |
#completion = generation_model.predict(prompt = prompt,
|
43 |
# max_output_tokens = config["max_output_tokens"],
|
@@ -51,7 +54,7 @@ def invoke(prompt):
|
|
51 |
# "top_k": config["top_k"],
|
52 |
# "top_p": config["top_p"],
|
53 |
# }).text
|
54 |
-
#
|
55 |
#return completion
|
56 |
return "🛑 Execution is commented out. To view the source code see https://huggingface.co/spaces/bstraehle/google-vertex-ai-llm/tree/main."
|
57 |
|
|
|
17 |
"top_p": 1.0,
|
18 |
}
|
19 |
|
|
|
|
|
|
|
20 |
credentials = json.loads(credentials)
|
21 |
|
22 |
from google.oauth2 import service_account
|
|
|
35 |
from vertexai.preview.generative_models import GenerativeModel
|
36 |
generation_model = GenerativeModel(config["model"])
|
37 |
|
38 |
+
def wandb_log(prompt, completion):
|
39 |
+
wandb.login(key = wandb_api_key)
|
40 |
+
wandb.init(project = "vertex-ai-llm", config = config)
|
41 |
+
wandb.log({"prompt": prompt, "completion": completion})
|
42 |
+
wandb.finish()
|
43 |
+
|
44 |
def invoke(prompt):
|
45 |
#completion = generation_model.predict(prompt = prompt,
|
46 |
# max_output_tokens = config["max_output_tokens"],
|
|
|
54 |
# "top_k": config["top_k"],
|
55 |
# "top_p": config["top_p"],
|
56 |
# }).text
|
57 |
+
#wandb_log(prompt, completion)
|
58 |
#return completion
|
59 |
return "🛑 Execution is commented out. To view the source code see https://huggingface.co/spaces/bstraehle/google-vertex-ai-llm/tree/main."
|
60 |
|