Skip to content

Commit ecc5e35

Browse files
authored
Merge pull request #490 from AmosDinh/pre/beta
Ollama: Use no json format when creating the search query
2 parents 5137b8a + 05cf9ad commit ecc5e35

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

scrapegraphai/nodes/search_internet_node.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from ..utils.logging import get_logger
1111
from ..utils.research_web import search_on_web
1212
from .base_node import BaseNode
13+
from ..models import Ollama
1314

1415

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

9596
# Execute the chain to get the search query
9697
search_answer = search_prompt | self.llm_model | output_parser
97-
search_query = search_answer.invoke({"user_prompt": user_prompt})[0]
98+
99+
# Ollama: Use no json format when creating the search query
100+
if isinstance(self.llm_model, Ollama) and self.llm_model.format == 'json':
101+
self.llm_model.format = None
102+
search_query = search_answer.invoke({"user_prompt": user_prompt})[0]
103+
self.llm_model.format = 'json'
104+
else:
105+
search_query = search_answer.invoke({"user_prompt": user_prompt})[0]
98106

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

0 commit comments

Comments
 (0)