Skip to content
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

Incorrect LLM Used and API Environment Variable Warnings #642

Open
jukti3742 opened this issue Oct 25, 2024 · 3 comments
Open

Incorrect LLM Used and API Environment Variable Warnings #642

jukti3742 opened this issue Oct 25, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@jukti3742
Copy link

When running the script, I encountered two main issues:

  1. The library defaults to using the GPT-4o model despite setting the LLM to gpt-4o-mini, leading to higher costs.
  2. I received warnings about missing environment variables for external APIs, for reasons unknown to me.

Code Snippet:

import os
from paperqa import Docs, Settings
.
.
.
doc_paths = get_absolute_paths(folder_path)
docs = Docs()

for doc in doc_paths:
    docs.add(doc)

settings = Settings()
settings.llm = "gpt-4o-mini"
settings.summary_llm = "gpt-4o-mini"
settings.prompts.qa = my_qa_prompt
# settings.answer.answer_max_sources = 3

answer = docs.query(
    question,
    settings=settings,
)

print(answer.formatted_answer)

Warnings:

SEMANTIC_SCHOLAR_API_KEY environment variable not set. Semantic Scholar API rate limits may apply.
CROSSREF_MAILTO environment variable not set. Crossref API rate limits may apply.
CROSSREF_API_KEY environment variable not set. Crossref API rate limits may apply.
Copy link

dosubot bot commented Oct 25, 2024

Hey there, @jukti3742! I'm Dosu, a bot here to help you with bugs, questions, and becoming a contributor. Let's tackle this issue together while we wait for a human maintainer.

  1. LLM Defaulting Issue: The paperqa library defaults to using "gpt-4o-2024-08-06" as the LLM. If your script is still using this model despite setting settings.llm and settings.summary_llm to "gpt-4o-mini", ensure that these settings are correctly applied before the query method is called. Double-check that there are no other parts of your code or library defaults that might override these settings.

  2. Environment Variable Warnings: The warnings about missing environment variables indicate that the library is trying to access external APIs without the necessary credentials. For Semantic Scholar and Crossref, you need to set the SEMANTIC_SCHOLAR_API_KEY, CROSSREF_MAILTO, and CROSSREF_API_KEY environment variables to avoid rate limits. You can set these in your environment using:

    export SEMANTIC_SCHOLAR_API_KEY='your_api_key'
    export CROSSREF_MAILTO='your_email'
    export CROSSREF_API_KEY='your_api_key'

    These variables are crucial for accessing the APIs without hitting rate limits [1][2].

To continue talking to Dosu, mention @dosu.

@dosubot dosubot bot added the bug Something isn't working label Oct 25, 2024
@jukti3742
Copy link
Author

Not helpful, since settings are correctly set to "gpt-4o-mini" before the query method is called. Please see the code snippet.

@mmtftr
Copy link

mmtftr commented Nov 3, 2024

For the warnings, please read https://github.com/Future-House/paper-qa#installation

For the model selection issue:

I had the same problem as you, and realized that the documentation is not updated to reflect API changes.

The model settings are actually taken from the agent key of the Settings object, and not the llm or summary_llm as the docs would suggest. The fix is to also give your model name inside that key as follows:

from paperqa.agents.main import AgentSettings

settings=Settings(
  agent=AgentSettings(
    agent_llm="gpt-4o-mini", # your desired LLM
  ),
)

If this fixes your problem, please close the issue, I'll be opening a new issue for the stale docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants