anmolsahai commited on
Commit
559b6b9
1 Parent(s): 322dc90

bugresolve

Browse files
Files changed (1) hide show
  1. langchain_pipeline.py +12 -7
langchain_pipeline.py CHANGED
@@ -6,16 +6,21 @@ from langchain_openai import OpenAIEmbeddings
6
  from langchain_anthropic import ChatAnthropic
7
  from langchain_google_genai import ChatGoogleGenerativeAI
8
  import base64
9
- from google.cloud.aiplatform.generative_models import GenerativeModel, Part, FinishReason
10
- from google.cloud import aiplatform as generative_models
 
11
 
12
  def generate(document_parts, prompt_text):
13
  aiplatform.init(project="akroda", location="us-central1")
14
- model = GenerativeModel("gemini-1.5-pro-001")
15
- responses = model.generate_content(
16
- document_parts,
17
- generation_config=generation_config,
18
- safety_settings=safety_settings,
 
 
 
 
19
  stream=True,
20
  )
21
 
 
6
  from langchain_anthropic import ChatAnthropic
7
  from langchain_google_genai import ChatGoogleGenerativeAI
8
  import base64
9
+ from google.cloud import aiplatform
10
+ from google.cloud.aiplatform.gapic.services.model_service import client as model_client
11
+ from google.cloud.aiplatform.gapic.services.model_service.types import generative_model
12
 
13
  def generate(document_parts, prompt_text):
14
  aiplatform.init(project="akroda", location="us-central1")
15
+ model_service_client = model_client.ModelServiceClient()
16
+ model_resource_name = model_service_client.model_path("akroda", "us-central1", "gemini-1.5-pro-001")
17
+ response = model_service_client.generate_content(
18
+ request=generative_model.GenerateContentRequest(
19
+ model=model_resource_name,
20
+ documents=document_parts,
21
+ prompt=prompt_text,
22
+ generation_config=generation_config,
23
+ safety_settings=safety_settings,
24
  stream=True,
25
  )
26