Skip to content

Ollama: Use no json format when creating the search query #490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion scrapegraphai/nodes/search_internet_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from ..utils.logging import get_logger
from ..utils.research_web import search_on_web
from .base_node import BaseNode
from ..models import Ollama


class SearchInternetNode(BaseNode):
Expand Down Expand Up @@ -94,7 +95,14 @@ def execute(self, state: dict) -> dict:

# Execute the chain to get the search query
search_answer = search_prompt | self.llm_model | output_parser
search_query = search_answer.invoke({"user_prompt": user_prompt})[0]

# Ollama: Use no json format when creating the search query
if isinstance(self.llm_model, Ollama) and self.llm_model.format == 'json':
self.llm_model.format = None
search_query = search_answer.invoke({"user_prompt": user_prompt})[0]
self.llm_model.format = 'json'
else:
search_query = search_answer.invoke({"user_prompt": user_prompt})[0]

self.logger.info(f"Search Query: {search_query}")

Expand Down