Update app.py
Browse files
app.py
CHANGED
@@ -34,19 +34,24 @@ vertexai.init(project = project,
|
|
34 |
credentials = credentials
|
35 |
)
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
from vertexai.preview.generative_models import GenerativeModel
|
40 |
-
generation_model = GenerativeModel(config.model)
|
41 |
|
42 |
def invoke(prompt):
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
50 |
wandb.log({"prompt": prompt, "completion": completion})
|
51 |
return completion
|
52 |
#return "Execution is commented out, to view the source code see https://huggingface.co/spaces/bstraehle/google-vertex-ai-llm/tree/main."
|
|
|
34 |
credentials = credentials
|
35 |
)
|
36 |
|
37 |
+
from vertexai.language_models import TextGenerationModel
|
38 |
+
generation_model = TextGenerationModel.from_pretrained(config.model)
|
39 |
+
#from vertexai.preview.generative_models import GenerativeModel
|
40 |
+
#generation_model = GenerativeModel(config.model)
|
41 |
|
42 |
def invoke(prompt):
|
43 |
+
completion = generation_model.predict(prompt = prompt,
|
44 |
+
max_output_tokens = config.max_output_tokens,
|
45 |
+
temperature = config.temperature,
|
46 |
+
top_k = config.top_k,
|
47 |
+
top_p = config.top_p,
|
48 |
+
).text
|
49 |
+
#completion = generation_model.generate_content(prompt, generation_config = {
|
50 |
+
# "max_output_tokens": config.max_output_tokens,
|
51 |
+
# "temperature": config.temperature,
|
52 |
+
# "top_k": config.top_k,
|
53 |
+
# "top_p": config.top_p,
|
54 |
+
# }).text
|
55 |
wandb.log({"prompt": prompt, "completion": completion})
|
56 |
return completion
|
57 |
#return "Execution is commented out, to view the source code see https://huggingface.co/spaces/bstraehle/google-vertex-ai-llm/tree/main."
|