Skip to content

Commit

Permalink
dummy init classes
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleclo committed Nov 8, 2024
1 parent 11fbd77 commit 20b3f4d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
20 changes: 20 additions & 0 deletions contexteval/contexteval.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
Main classes for ContextEval
@kylel
"""

from typing import Dict, List


class DummyContextEval:
def __init__(self, *args, **kwargs):
pass

def generate_contexts(self, query: str, answer: str, *args, **kwargs):
return [{"q": "What?", "a": "This."}, {"q": "Why?", "a": "Because."}]

def evaluate(self, contexts: List[Dict[str, str]], *args, **kwargs):
return {"score": 0.5, "contexts": contexts}
24 changes: 24 additions & 0 deletions tests/test_contexteval.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""
Tests for main ContextEval
@kylel
"""

import unittest

from contexteval.contexteval import DummyContextEval


class TestContextEval(unittest.TestCase):
def test_generate_contexts(self):
ce = DummyContextEval()
contexts = ce.generate_contexts("query", "answer")
self.assertEqual(contexts, [{"q": "What?", "a": "This."}, {"q": "Why?", "a": "Because."}])

def test_evaluate(self):
ce = DummyContextEval()
contexts = [{"q": "What?", "a": "This."}, {"q": "Why?", "a": "Because."}]
result = ce.evaluate(contexts)
self.assertEqual(result, {"score": 0.5, "contexts": contexts})

0 comments on commit 20b3f4d

Please sign in to comment.