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

fix(chat): update data keys #923

Merged
merged 1 commit into from
Aug 10, 2023
Merged

fix(chat): update data keys #923

merged 1 commit into from
Aug 10, 2023

Conversation

mamadoudicko
Copy link
Contributor

Description

Fix prod

@mamadoudicko mamadoudicko temporarily deployed to preview August 10, 2023 16:32 — with GitHub Actions Inactive
@vercel
Copy link

vercel bot commented Aug 10, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 10, 2023 4:33pm
quivrapp 🔄 Building (Inspect) Visit Preview Aug 10, 2023 4:33pm

@github-actions
Copy link
Contributor

Risk Level 2 - /home/runner/work/quivr/quivr/backend/core/llm/qa_base.py

The code seems to be well written and follows the SOLID principles. However, there are a few areas that could be improved for better readability and maintainability.

  1. Hardcoded Strings: There are several hardcoded strings in the code. It would be better to define these as constants at the top of the file or in a separate configuration file. This would make it easier to manage and modify these values.

For example, the string 'vectors' in the _create_vector_store method could be defined as a constant:

VECTORS_TABLE_NAME = 'vectors'

And then used in the method like so:

return CustomSupabaseVectorStore(
    self.supabase_client,
    self.embeddings,
    table_name=VECTORS_TABLE_NAME,
    brain_id=self.brain_id,
)
  1. Error Handling: There are some places in the code where error handling could be improved. For example, in the generate_stream method, there is a try/except block that catches all exceptions and logs an error message. It would be better to catch specific exceptions and handle them appropriately. This would make it easier to debug issues and prevent unexpected behavior.

For example:

try:
    await fn
except SpecificException as e:
    logger.error(f\"Caught SpecificException: {e}\")
except Exception as e:
    logger.error(f\"Caught unexpected exception: {e}\")
finally:
    event.set()
  1. Code Duplication: There is some code duplication in the generate_answer and generate_stream methods. It would be better to extract this common code into a separate method. This would make the code easier to maintain and test.

For example, the code to create a ConversationalRetrievalChain could be extracted into a separate method:

def _create_qa_chain(self, answering_llm, doc_chain):
    return ConversationalRetrievalChain(
        retriever=self.vector_store.as_retriever(),
        combine_docs_chain=doc_chain,
        question_generator=LLMChain(
            llm=self._create_llm(model=self.model), prompt=CONDENSE_QUESTION_PROMPT
        ),
        verbose=True,
    )

And then used in the generate_answer and generate_stream methods like so:

qa = self._create_qa_chain(answering_llm, doc_chain)

🔤🚫🔁


Powered by Code Review GPT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants