Scrapegraph-ai
Scrapegraph-ai copied to clipboard
Adding message parameter support for OpenAI models
OpenAI models uses the message parameter for the prompt. ScrapegraphAI also use this parameter to link to the prompt argument on scrapper invocation. However, sometimes when using openAI models, we need to make multiple prompts to better guide the response (like in this article and this documentation).
Is it possible to replace the standart scrapGraphAI prompt when providing message argument in the graph_config ?
Example :
import os
from scrapegraphai.graphs import SmartScraperGraph
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
system_prompt = "Provide output in valid JSON."
user_prompt = "List me all the news article with a brief description for each one."
graph_config = {
"llm": {
"api_key": OPENAI_API_KEY,
"model": "gpt-3.5-turbo",
"response_format": {"type": "json_object"},
"seed": 0,
"temperature": 0,
"messages": [
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_prompt},
],
},
"verbose": True,
}
smart_scraper_graph = SmartScraperGraph(
prompt=user_prompt,
# also accepts a string with the already downloaded HTML code
source="https://perinim.github.io/projects",
config=graph_config,
)
# TypeError: openai.resources.chat.completions.Completions.create() got multiple values for keyword argument 'messages'```
ok, it could be an idea but please provide me a use case for the system prompt. The output is already in the json format
Even if the output format is in json?
Yes, according to the groq playground, the system message should contain the word JSON
El El sáb, 15 de jun de 2024 a la(s) 12:38 a.m., Marco Vinciguerra < @.***> escribió:
Even if the output format is in json?
— Reply to this email directly, view it on GitHub https://github.com/VinciGit00/Scrapegraph-ai/issues/382#issuecomment-2169163134, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADSHIVDNBCXIYAE2PY3ZGLZHPOPNAVCNFSM6AAAAABJKD63P6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRZGE3DGMJTGQ . You are receiving this because you commented.Message ID: @.***>
give me an example please
Hi, @Hkllopp. I'm Dosu, and I'm helping the Scrapegraph-ai team manage their backlog. I'm marking this issue as stale.
Issue Summary:
- You requested support for the 'messages' parameter in OpenAI models to enhance multi-prompt responses.
- Encountered a TypeError due to conflicting arguments when using this parameter.
- @VinciGit00 asked for a use case for the system prompt.
- @ehecatl provided an example involving the word "JSON" in the system-prompt message.
- Discussion continued with @VinciGit00 requesting further examples.
Next Steps:
- Please confirm if this issue is still relevant to the latest version of the Scrapegraph-ai repository by commenting here.
- If there is no further activity, this issue will be automatically closed in 7 days.
Thank you for your understanding and contribution!