Skip to content

Commit

Permalink
format fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shahules786 committed Jun 18, 2024
1 parent 3cfdaf7 commit e76a4ed
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/ragas/testsetv3/graph.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import uuid

from graphene import Argument, Enum, Field, JSONString, List, ObjectType, Schema, String

import typing as t
from graphene import Argument, Field, JSONString, List, ObjectType, Schema, String
from enum import Enum

class NodeType(Enum):
DOC = "doc"
Expand All @@ -13,7 +13,7 @@ class NodeLevel(Enum):
LEVEL_1 = 1
LEVEL_2 = 2

def next_level(self):
def next_level(self) -> t.Optional['NodeLevel']:
level_values = list(NodeLevel)
current_index = level_values.index(self)
next_index = current_index + 1
Expand Down
22 changes: 13 additions & 9 deletions src/ragas/testsetv3/questions/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,19 @@ async def generate_question(
if critic_verdict:
source = await self.retrieve_chunks(question, current_nodes, kwargs)
question = await self.modify_question(question)
answer = await self.generate_answer(question, source)
return QAC(
question=question,
answer=answer,
source=source,
name=self.name,
style=self.style,
length=self.length,
)
if source:
answer = await self.generate_answer(question, source)
return QAC(
question=question,
answer=answer,
source=source,
name=self.name,
style=self.style,
length=self.length,
)
else:
logger.warning("source not found: %s", question)
return QAC()
else:
logger.warning("Critic rejected the question: %s", question)
return QAC()
Expand Down
2 changes: 1 addition & 1 deletion src/ragas/testsetv3/questions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def retrieve_chunks(

async def modify_question(self, question: str) -> str:
assert self.llm is not None, "LLM is not initialized"
question_modification_prompt_ = self.question_modification_prompt
question_modification_prompt_ = self.question_modification_prompt.copy()
examples = [
example
for example in self.question_modification_prompt.examples
Expand Down

0 comments on commit e76a4ed

Please sign in to comment.