Update app.py
Browse files
app.py
CHANGED
@@ -16,29 +16,22 @@ wandb.login(key = wandb_api_key)
|
|
16 |
wandb.init(project = "vertext-ai-txt", config = config)
|
17 |
config = wandb.config
|
18 |
|
19 |
-
|
20 |
|
21 |
from google.oauth2 import service_account
|
22 |
-
|
23 |
|
24 |
-
|
25 |
-
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
|
31 |
from vertexai.language_models import TextGenerationModel
|
32 |
generation_model = TextGenerationModel.from_pretrained("text-bison@001")
|
33 |
|
34 |
-
def invoke(prompt
|
35 |
-
credentials = json.loads(credentials)
|
36 |
-
credentials = service_account.Credentials.from_service_account_info(credentials)
|
37 |
-
if credentials.expired:
|
38 |
-
credentials.refresh(Request())
|
39 |
-
vertexai.init(project = project,
|
40 |
-
location = "us-central1",
|
41 |
-
credentials = credentials)
|
42 |
completion = generation_model.predict(prompt = prompt).text
|
43 |
wandb.log({"prompt": prompt, "completion": completion})
|
44 |
return completion
|
|
|
16 |
wandb.init(project = "vertext-ai-txt", config = config)
|
17 |
config = wandb.config
|
18 |
|
19 |
+
credentials = json.loads(credentials)
|
20 |
|
21 |
from google.oauth2 import service_account
|
22 |
+
credentials = service_account.Credentials.from_service_account_info(credentials)
|
23 |
|
24 |
+
if credentials.expired:
|
25 |
+
credentials.refresh(Request())
|
26 |
|
27 |
+
vertexai.init(project = project,
|
28 |
+
location = "us-central1",
|
29 |
+
credentials = credentials)
|
30 |
|
31 |
from vertexai.language_models import TextGenerationModel
|
32 |
generation_model = TextGenerationModel.from_pretrained("text-bison@001")
|
33 |
|
34 |
+
def invoke(prompt):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
completion = generation_model.predict(prompt = prompt).text
|
36 |
wandb.log({"prompt": prompt, "completion": completion})
|
37 |
return completion
|