-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89c82c3
commit 797c818
Showing
10 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ web3==6.15.1 | |
google-cloud-storage==2.14.0 | ||
pytest==8.1.1 | ||
pytest-cov==4.1.0 | ||
pytest-asyncio==0.23.6 | ||
groq==0.4.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import pytest | ||
|
||
from src.entities import Chat | ||
from src.entities import PromptType | ||
from src.entities import GroqConfig | ||
from src.domain.llm import generate_response_use_case | ||
|
||
MESSAGES = [{"role": "user", "content": "Hello"}] | ||
|
||
|
||
async def _get_config(model: str) -> GroqConfig: | ||
return GroqConfig( | ||
model=model, | ||
frequency_penalty=0.0, | ||
logit_bias=None, | ||
max_tokens=100, | ||
presence_penalty=0.0, | ||
response_format=None, | ||
seed=None, | ||
stop=None, | ||
temperature=0.0, | ||
top_p=1.0, | ||
user=None, | ||
) | ||
|
||
|
||
async def _get_chat(model: str) -> Chat: | ||
return Chat( | ||
id="1", | ||
callback_id="1", | ||
is_processed=False, | ||
prompt_type=PromptType.GROQ.value, | ||
messages=MESSAGES, | ||
config=await _get_config(model), | ||
) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_mixtral(): | ||
chat = await _get_chat("mixtral-8x7b-32768") | ||
result = await generate_response_use_case._generate_groq_with_params(chat) | ||
assert "hello" in result.choices[0].message.content.lower() | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_llama2_70b(): | ||
chat = await _get_chat("llama2-70b-4096") | ||
result = await generate_response_use_case._generate_groq_with_params(chat) | ||
assert "hello" in result.choices[0].message.content.lower() | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_gemma_7b_it(): | ||
chat = await _get_chat("gemma-7b-it") | ||
result = await generate_response_use_case._generate_groq_with_params(chat) | ||
assert "hello" in result.choices[0].message.content.lower() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import pytest | ||
|
||
from src.entities import Chat | ||
from src.entities import PromptType | ||
from src.entities import OpenAiConfig | ||
from src.domain.llm import generate_response_use_case | ||
|
||
MESSAGES = [{"role": "user", "content": "Just say Hello"}] | ||
|
||
|
||
async def _get_config(model: str) -> OpenAiConfig: | ||
return OpenAiConfig( | ||
model=model, | ||
frequency_penalty=0.0, | ||
logit_bias=None, | ||
max_tokens=100, | ||
presence_penalty=0.0, | ||
response_format=None, | ||
seed=None, | ||
stop=None, | ||
temperature=0.0, | ||
top_p=1.0, | ||
user=None, | ||
tools=None, | ||
tool_choice=None, | ||
) | ||
|
||
|
||
async def _get_chat(model: str) -> Chat: | ||
return Chat( | ||
id="1", | ||
callback_id="1", | ||
is_processed=False, | ||
prompt_type=PromptType.OPENAI.value, | ||
messages=MESSAGES, | ||
config=await _get_config(model), | ||
) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_gpt_3_5_turbo(): | ||
chat = await _get_chat("gpt-3.5-turbo-1106") | ||
result = await generate_response_use_case._generate_openai_with_params(chat) | ||
assert result is not None | ||
assert "hello" in result.choices[0].message.content.lower() | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_gpt_4_turbo(): | ||
chat = await _get_chat("gpt-4-turbo-preview") | ||
result = await generate_response_use_case._generate_openai_with_params(chat) | ||
assert result is not None | ||
assert "hello" in result.choices[0].message.content.lower() |
12 changes: 12 additions & 0 deletions
12
oracles/tests/integration/repositories/test_ipfs_repository.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import pytest | ||
|
||
from src.repositories.ipfs_repository import IpfsRepository | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_ipfs_repository(): | ||
ipfs = IpfsRepository() | ||
cid = await ipfs.write_file(bytes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) | ||
assert cid is not None | ||
data = await ipfs.read_file(cid) | ||
assert data == bytes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) |
16 changes: 16 additions & 0 deletions
16
oracles/tests/integration/repositories/test_oracle_repository.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pytest | ||
|
||
from src.repositories.oracle_repository import OracleRepository | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_oracle_repository(): | ||
oracle_repository = OracleRepository() | ||
chats = await oracle_repository.get_unanswered_chats() | ||
assert chats is not None | ||
functions = await oracle_repository.get_unanswered_function_calls() | ||
assert functions is not None | ||
kb_indexing_requests = await oracle_repository.get_unindexed_knowledge_bases() | ||
assert kb_indexing_requests is not None | ||
kb_queries = await oracle_repository.get_unanswered_kb_queries() | ||
assert kb_queries is not None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import pytest | ||
|
||
from src.domain.storage import reupload_to_gcp_use_case | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_reupload_to_gcp_use_case(): | ||
download_url = "https://picsum.photos/200/200" | ||
result = await reupload_to_gcp_use_case.execute(download_url) | ||
assert len(result) > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import pytest | ||
|
||
from src.domain.tools.image_generation import generate_image_use_case | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_generate_image_use_case(): | ||
query = "white horse" | ||
result = await generate_image_use_case.execute(query) | ||
assert len(result.url) > 0 | ||
assert result.error == "" |
18 changes: 18 additions & 0 deletions
18
oracles/tests/integration/tools/test_tool_code_interpreter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import pytest | ||
from src.domain.tools.code_interpreter import python_interpreter_use_case | ||
from src.domain.tools.code_interpreter.entities import PythonInterpreterResult | ||
|
||
|
||
def _format_json_output(stdout: str, stderr: str) -> str: | ||
return f'{{"stdout": "{stdout}", "stderr": "{stderr}"}}' | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_python_interpreter_success(): | ||
code = "print('Hello world')" | ||
result = await python_interpreter_use_case.execute(code) | ||
assert result == PythonInterpreterResult( | ||
output=_format_json_output("Hello world\\n", ""), | ||
error="", | ||
exit_code=0, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import pytest | ||
|
||
from src.domain.tools.search import web_search_use_case | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_web_search_use_case(): | ||
query = "test" | ||
result = await web_search_use_case.execute(query) | ||
assert len(result.result) > 0 | ||
assert result.error == "" |