Skip to content

Commit

Permalink
structuring
Browse files Browse the repository at this point in the history
  • Loading branch information
amirrr committed Jul 7, 2024
1 parent 698379a commit 158f93e
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 7 deletions.
69 changes: 69 additions & 0 deletions server/claude_function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
"""
Runs the Claude function call API.
"""

from typing import List


def get_all_features() -> List[str]:
"""
Gets all the available features.
Returns:
- List of all available features.
"""

experiments_features = [
"features.experiments.experiment_name",
"features.experiments.experiment_description",
"features.experiments.participant_source",
"features.experiments.participant_source_category",
"features.experiments.units_randomized",
"features.experiments.units_analyzed",
"features.experiments.sample_size_randomized",
"features.experiments.sample_size_analyzed",
"features.experiments.sample_size_notes",
"features.experiments.adults",
"features.experiments.age_mean",
"features.experiments.age_sd",
"features.experiments.female_perc",
"features.experiments.male_perc",
"features.experiments.gender_other",
"features.experiments.language",
"features.experiments.language_secondary",
"features.experiments.compensation",
"features.experiments.demographics_conditions",
"features.experiments.population_other",
"features.experiments.condition.name",
"features.experiments.condition.description",
"features.experiments.condition.type",
"features.experiments.condition.message",
"features.experiments.condition.behavior.name",
"features.experiments.condition.behavior.description",
"features.experiments.condition.behavior.priority",
"features.experiments.condition.behavior.focal",
]


experiments_function_call = {
"name": "define_experiments_conditions_and_behaviors",
"description": "Define the conditions and behaviors in each experiment. Each condition and behavior should be a separate object with specified properties and values under the experiments object.",
"parameters": {
"type": "object",
"properties": {
"experiments": {
"type": "array",
"description": "Array of experiments objects with detailed properties.",
"items": {
"type": "object",
"properties": {
"conditions": {},
},
},
},
},
"required": [
"experiments",
],
},
}
3 changes: 1 addition & 2 deletions server/controllers/assisstant.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
"""

import os
import json
from flask import jsonify, make_response, request
from flask_restful import Resource


from assistant import AssistantException, call_asssistant_api
from gpt_assistant import AssistantException, call_asssistant_api


UPLOAD_DIRECTORY = "../paper/"
Expand Down
30 changes: 30 additions & 0 deletions server/features/experiments/parent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
Experiments feature module.
"""

from features.gpt_feature import GPTFeature


class Feature(GPTFeature):
"""
Experiments feature. This feature is responsible for indicating the experiments in the study.
"""

def __init__(self, *args, **kwargs):
feature_name = "experiments"
feature_type = "object"
feature_prompt = (
"Define the experiments in this paper. "
"Each experiment should be a separate object with the following properties. " # This could be moved to where aggregation is done
)
feature_enum = None
feature_description = "The experiments in a paper."
super().__init__(
feature_name,
feature_type,
feature_prompt,
feature_enum,
feature_description,
*args,
**kwargs
)
8 changes: 4 additions & 4 deletions server/assistant.py → server/gpt_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ def get_all_features() -> tuple[List[str], List[str]]:
"features.experiments.condition.message",
],
[
"features.experiments.behavior.name",
"features.experiments.behavior.description",
"features.experiments.behavior.priority",
"features.experiments.behavior.focal",
"features.experiments.condition.behavior.name",
"features.experiments.condition.behavior.description",
"features.experiments.condition.behavior.priority",
"features.experiments.condition.behavior.focal",
],
)

Expand Down
2 changes: 1 addition & 1 deletion server/test_assistant.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
from unittest.mock import Mock, patch
from .assistant import call_asssistant_api
from .gpt_assistant import call_asssistant_api


class TestAssistantAPI(unittest.TestCase):
Expand Down

0 comments on commit 158f93e

Please sign in to comment.