jiggy-ai / jiggybase

python client for JiggyBase
Apache License 2.0
8 stars 4 forks source link

cannot import create_prompt_task #1

Closed EmanuelLM closed 1 year ago

EmanuelLM commented 1 year ago
Hi Team,

I encountered an issue while trying to import the 'create_prompt_task' function from the 'jiggybase' module as instructed in the readme.md. I got an 'ImportError: cannot import name 'create_prompt_task' from 'jiggybase''. This error occurred while running Python version 3.10.

I've included the code and error below for reference :

from jiggybase.models import PromptMessage
from jiggybase import create_prompt_task

prompts = [

PromptMessage(
    content="Does Apple undertake climate scenario planning? Please provide direct evidence from the report in the collection called ‘Climate disclosures’. If there’s isn’t enough evidence, express the fact that the report has not enough information to answer conclusively.",
    role="user",
    position=1,
    extras=None,
    ),

    PromptMessage(
    content="Does Apple disclose an internal price of carbon? Please provide direct evidence from the report in the collection called ‘Climate disclosures’. If there’s isn’t enough evidence, express the fact that the report has not enough information to answer conclusively.",
    role="user",
    position=1,
    extras=None,
    ),

    PromptMessage(
    content="Does Apple ensure consistency between its climate change policy and the positions taken by trade associations of which it is a member? Please provide direct evidence from the report in the collection called ‘Climate disclosures’. If there’s isn’t enough evidence, express the fact that the report has not enough information to answer conclusively.",
    role="user",
    position=1,
    extras=None,
    )
]

# Create the prompt task
create_prompt_task(
    name="Apple_Climate_Change",
    version=1,
    prompts=prompts,
    type=None,
    description="Apple 2022 ESG report"
)
#Here's the error : 
ImportError                               Traceback (most recent call last)

<ipython-input-19-ea878baf213f> in <cell line: 3>()
      1 # Import the necessary modules
      2 from jiggybase.models import PromptMessage
----> 3 from jiggybase import create_prompt_task
      4 
      5 # Define the prompts

ImportError: cannot import name 'create_prompt_task' from 'jiggybase' (/usr/local/lib/python3.10/dist-packages/jiggybase/__init__.py)`

Could you please assist me in resolving this issue? Thanks in advance for your help.

Best, ELM

amy-why commented 1 year ago

create_prompt_task is a function for an org:

import jiggybase
jb = jiggybase.JiggyBase()
a = jb.orgs()
a[0].create_prompt_task(...)

where

Signature:
a[0].create_prompt_task(
    name: str,
    version: int,
    prompts: List[jiggybase.models.prompt.PromptMessage],
    type: Optional[jiggybase.models.prompt.PromptTaskType] = None,
    description: Optional[str] = None,
) -> jiggybase.models.prompt.PromptTask