from __future__ import annotations import os from langchain.prompts import PromptTemplate from langchain.chat_models import ChatOpenAI from typing import Any from langchain.base_language import BaseLanguageModel from langchain.chains.llm import LLMChain import streamlit as st import vertexai from vertexai.language_models import TextGenerationModel, TextEmbeddingModel PROJECT_ID = "agileai-poc" vertexai.init(project=PROJECT_ID, location="us-central1") parameters = { "max_output_tokens": 256, "temperature": 0.2, "top_p": 0.8, } generation_model = TextGenerationModel.from_pretrained("text-bison@001") print("model called") response = generation_model.predict( "Generate a product description that is creative and SEO compliant. Emojis should be added to make product description look appealing. Begin!", **parameters) print(response) embedding_model = TextEmbeddingModel.from_pretrained("textembedding-gecko@001") print("model2 called") prompt_file = "prompt_template.txt" print(prompt_file) print(generation_model.predict("describe", **parameters)) print(embedding_model.predict("describe", **parameters)) tuned_model = generation_model.list_tuned_model_names() print("******", tuned_model) # prod_nm = st.text_input("Product Name") # keywords = st.text_input("Filters") # style = st.selectbox("Select the response style", [ # "Funny", "Sarcastic", "Casual"]) # generate = st.button("Generate Product Description") # params = { # prod_nm = st.text_input("Product Name"), # keywords = st.text_input("Filters"), # style = st.selectbox("Select the response style", [ # "Funny", "Sarcastic", "Casual"]) # } # if generate: # message = st.empty() # message.text("Describing...") # content = (generation_model.predict( # "Generate a product description that is creative and SEO compliant. Emojis should be added to make product description look appealing. Begin!", **params) # ) # message.text("") # st.write(content) # params={ # prod_num # }