-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moves llm functions into subclasses (#111)
* Create classes for LLM endpoints * Test the openai + gemini classes
- Loading branch information
1 parent
ba2fddc
commit 96c49a1
Showing
15 changed files
with
686 additions
and
343 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
This file was deleted.
Oops, something went wrong.
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,30 @@ | ||
"Contains all functions that call OpenAI's API." | ||
|
||
from __future__ import annotations | ||
|
||
|
||
class LLMBase: | ||
def __init__(self, api_key, model=None): # pragma: no cover | ||
self.client = None | ||
self.model = model | ||
|
||
def get_definitions(self, headers, language): # pragma: no cover | ||
""" | ||
Get the definitions of the columns in the dataset. | ||
""" | ||
# subclasses should implement this method | ||
raise NotImplementedError | ||
|
||
def map_fields(self, source_fields, target_fields): # pragma: no cover | ||
""" | ||
Calls the OpenAI API to generate a draft mapping between two datasets. | ||
""" | ||
# subclasses should implement this method | ||
raise NotImplementedError | ||
|
||
def map_values(self, values, language): # pragma: no cover | ||
""" | ||
Calls the OpenAI API to generate a set of value mappings for the fields. | ||
""" | ||
# subclasses should implement this method | ||
raise NotImplementedError |
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,41 @@ | ||
"""Stores the data structures for using with LLM API's""" | ||
|
||
from __future__ import annotations | ||
|
||
from pydantic import BaseModel | ||
|
||
# target classes for generating descriptions | ||
|
||
|
||
class SingleField(BaseModel): | ||
field_name: str | ||
translation: str | None | ||
|
||
|
||
class ColumnDescriptionRequest(BaseModel): | ||
field_descriptions: list[SingleField] | ||
|
||
|
||
# target classes for matching fields | ||
class SingleMapping(BaseModel): | ||
target_field: str | ||
source_description: str | None | ||
|
||
|
||
class MappingRequest(BaseModel): | ||
targets_descriptions: list[SingleMapping] | ||
|
||
|
||
# target classes for matching values to enum/boolean options | ||
class ValueMapping(BaseModel): | ||
source_value: str | ||
target_value: str | None | ||
|
||
|
||
class FieldMapping(BaseModel): | ||
field_name: str | ||
mapped_values: list[ValueMapping] | ||
|
||
|
||
class ValuesRequest(BaseModel): | ||
values: list[FieldMapping] |
Oops, something went wrong.