Merge pull request #341 from khalid-faiz/v3
Adding Google Gemini Implementation
This commit is contained in:
commit
99b74fbb61
3 changed files with 21 additions and 6 deletions
|
|
@ -153,7 +153,7 @@ This file contains sensitive information. Never share or commit this file to ver
|
|||
- Replace with your LinkedIn account email address
|
||||
- `password: [Your LinkedIn password]`
|
||||
- Replace with your LinkedIn account password
|
||||
- `llm_api_key: [Your OpenAI or Ollama API key]`
|
||||
- `llm_api_key: [Your OpenAI or Ollama API key or Gemini API key]`
|
||||
- Replace with your OpenAI API key for GPT integration
|
||||
- To obtain an API key, follow the tutorial at: https://medium.com/@lorenzozar/how-to-get-your-own-openai-api-key-f4d44e60c327
|
||||
- Note: You need to add credit to your OpenAI account to use the API. You can add credit by visiting the [OpenAI billing dashboard](https://platform.openai.com/account/billing).
|
||||
|
|
@ -162,6 +162,7 @@ This file contains sensitive information. Never share or commit this file to ver
|
|||
`{'error': {'message': 'Rate limit reached for gpt-4o-mini in organization <org> on requests per day (RPD): Limit 200, Used 200, Requested 1.}}`
|
||||
OpenAI will update your account automatically, but it might take some time, ranging from a couple of hours to a few days.
|
||||
You can find more about your organization limits on the [official page](https://platform.openai.com/settings/organization/limits).
|
||||
- For obtaining Gemini API key visit [Google AI for Devs](https://ai.google.dev/gemini-api/docs/api-key)
|
||||
|
||||
|
||||
### 2. config.yaml
|
||||
|
|
@ -225,17 +226,19 @@ This file defines your job search parameters and bot behavior. Each section cont
|
|||
#### 2.1 config.yaml - Customize LLM model endpoint
|
||||
|
||||
- `llm_model_type`:
|
||||
- Choose the model type, supported: openai / ollama / claude
|
||||
- Choose the model type, supported: openai / ollama / claude / gemini
|
||||
- `llm_model`:
|
||||
- Choose the LLM model, currently supported:
|
||||
- openai: gpt-4o
|
||||
- ollama: llama2, mistral:v0.3
|
||||
- claude: any model
|
||||
- gemini: any model
|
||||
- `llm_api_url`:
|
||||
- Link of the API endpoint for the LLM model
|
||||
- openai: https://api.pawan.krd/cosmosrp/v1
|
||||
- ollama: http://127.0.0.1:11434/
|
||||
- claude: https://api.anthropic.com/v1
|
||||
- gemini: no api_url
|
||||
- Note: To run local Ollama, follow the guidelines here: [Guide to Ollama deployment](https://github.com/ollama/ollama)
|
||||
|
||||
### 3. plain_text_resume.yaml
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ pdfminer.six==20221105
|
|||
inputimeout==1.0.4
|
||||
langchain-ollama==0.1.3
|
||||
langchain-anthropic==0.1.3
|
||||
langchain-google-genai==1.0.10
|
||||
jsonschema==4.23.0
|
||||
jsonschema-specifications==2023.12.1
|
||||
httpx~=0.27.2
|
||||
|
|
|
|||
19
src/gpt.py
19
src/gpt.py
|
|
@ -62,6 +62,16 @@ class OllamaModel(AIModel):
|
|||
return response
|
||||
|
||||
|
||||
class GeminiModel(AIModel):
|
||||
def __init__(self, api_key:str, llm_model: str, llm_api_url: str):
|
||||
from langchain_google_genai import ChatGoogleGenerativeAI
|
||||
self.model = ChatGoogleGenerativeAI(model=llm_model, google_api_key=api_key)
|
||||
|
||||
def invoke(self, prompt: str) -> str:
|
||||
response = self.model.invoke(prompt)
|
||||
return response
|
||||
|
||||
|
||||
class AIAdapter:
|
||||
def __init__(self, config: dict, api_key: str):
|
||||
self.model = self._create_model(config, api_key)
|
||||
|
|
@ -79,6 +89,8 @@ class AIAdapter:
|
|||
return ClaudeModel(api_key, llm_model, llm_api_url)
|
||||
elif llm_model_type == "ollama":
|
||||
return OllamaModel(api_key, llm_model, llm_api_url)
|
||||
elif llm_model_type == "gemini":
|
||||
return GeminiModel(api_key, llm_model, llm_api_url)
|
||||
else:
|
||||
raise ValueError(f"Unsupported model type: {llm_model_type}")
|
||||
|
||||
|
|
@ -88,7 +100,7 @@ class AIAdapter:
|
|||
|
||||
class LLMLogger:
|
||||
|
||||
def __init__(self, llm: Union[OpenAIModel, OllamaModel, ClaudeModel]):
|
||||
def __init__(self, llm: Union[OpenAIModel, OllamaModel, ClaudeModel, GeminiModel]):
|
||||
|
||||
self.llm = llm
|
||||
logger.debug("LLMLogger successfully initialized with LLM: %s", llm)
|
||||
|
|
@ -203,7 +215,7 @@ class LLMLogger:
|
|||
|
||||
class LoggerChatModel:
|
||||
|
||||
def __init__(self, llm: Union[OpenAIModel, OllamaModel, ClaudeModel]):
|
||||
def __init__(self, llm: Union[OpenAIModel, OllamaModel, ClaudeModel, GeminiModel]):
|
||||
self.llm = llm
|
||||
logger.debug(
|
||||
"LoggerChatModel successfully initialized with LLM: %s", llm)
|
||||
|
|
@ -494,8 +506,7 @@ class GPTAnswerer:
|
|||
if resume_section is None:
|
||||
logger.error(
|
||||
"Section '%s' not found in either resume or job_application_profile.", section_name)
|
||||
raise ValueError(f"Section '{
|
||||
section_name}' not found in either resume or job_application_profile.")
|
||||
raise ValueError(f"Section '{section_name}' not found in either resume or job_application_profile.")
|
||||
chain = chains.get(section_name)
|
||||
if chain is None:
|
||||
logger.error("Chain not defined for section '%s'", section_name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue