Skip to content

Commit

Permalink
Fix sphinx warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
volkerstampa committed Oct 30, 2023
1 parent d5c3afa commit 5925cd9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
5 changes: 5 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon", "sphinx.ext.viewcode"]

autodoc_default_options = {
"private-members": None,
"exclude-members": "model_config,model_fields",
}

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

Expand Down
2 changes: 1 addition & 1 deletion src/intelligence_layer/core/complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class InstructOutput(BaseModel):
Attributes:
response: The generated response to the instruction.
prompt_with_metadata: To handle the instruction, a `PromptTemplate` is used.
The template defines two `PromptRange`s:
The template defines two `PromptRange`\ s:
- "instruction": covering the instruction text as provided in the `InstructionInput`.
- "input": covering the input text as provided in the `InstructionInput`.
These can for example be used for downstream `TextHighlight` tasks.
Expand Down
9 changes: 7 additions & 2 deletions src/intelligence_layer/core/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

@runtime_checkable
class DebugLogger(Protocol):
"""A protocol for instrumenting `Task`s with structured logging.
"""A protocol for instrumenting `Task`\ s with structured logging.
A logger needs to provide a way to collect an individual log, which should be serializable, and
a way to generate nested loggers, so that sub-tasks can emit logs that are grouped together.
Expand Down Expand Up @@ -393,6 +393,11 @@ def _rich_render_(self) -> Tree:
return tree


# Required for sphinx, see also: https://docs.pydantic.dev/2.4/errors/usage_errors/#class-not-fully-defined
InMemorySpan.model_rebuild()
InMemoryDebugLogger.model_rebuild()


class StartTask(BaseModel):
"""Represents the payload/entry of a log-line indicating that a `TaskSpan` was opened through `DebugLogger.task_span`.
Expand Down Expand Up @@ -498,7 +503,7 @@ class FileDebugLogger(DebugLogger):
log_file_path: Denotes the file to log to.
Attributes:
uuid: a uuid for the logger. If multiple `FileDebugLogger`s log to the same file
uuid: a uuid for the logger. If multiple `FileDebugLogger`\ s log to the same file
the child-elements for a logger can be identified by referring to this id as parent.
"""

Expand Down
2 changes: 1 addition & 1 deletion src/intelligence_layer/core/prompt_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class PromptWithMetadata:
Args:
prompt: The actual `Prompt`.
ranges: A mapping of range name to a `Sequence` of corresponding `PromptRange`s.
ranges: A mapping of range name to a `Sequence` of corresponding `PromptRange`\ s.
"""

prompt: Prompt
Expand Down
5 changes: 3 additions & 2 deletions src/intelligence_layer/core/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class Task(ABC, Generic[Input, Output]):
Input: Interface to be passed to the task with all data needed to run the process.
Ideally, these are specified in terms related to the use-case, rather than lower-level
configuration options.
Output: Interface of the output returned by the task.
"""

Expand Down Expand Up @@ -111,8 +112,8 @@ def run_concurrently(
this method call. This can be used to prevent queue-full or similar error of downstream APIs
when the global concurrency limit is too high for a certain task.
Returns:
The `Output`s generated by calling `run` for each given `Input`. The order of `Output`s
corresponds to the order of the `Input`s.
The `Output`\ s generated by calling `run` for each given `Input`. The order of `Output`\ s
corresponds to the order of the `Input`\ s.
"""

with debug_logger.span(f"Concurrent {type(self).__name__} tasks") as span:
Expand Down
3 changes: 2 additions & 1 deletion src/intelligence_layer/core/text_highlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ class TextHighlight(Task[TextHighlightInput, TextHighlightOutput]):
client: Aleph Alpha client instance for running model related API calls.
Example:
>>> client = Client(os.getenv("AA_TOKEN"))
>>> text_highlight = TextHighlight(client=client)
>>> prompt_template_str = "{% promptrange r1 %}Question: What is 2 + 2?{% endpromptrange %}\nAnswer:"
>>> prompt_template_str = "{% promptrange r1 %\Question: What is 2 + 2?{% endpromptrange %}\\nAnswer:"
>>> template = PromptTemplate(prompt_template_str)
>>> prompt_with_metadata = template.to_prompt_with_metadata()
>>> completion = " 4."
Expand Down

0 comments on commit 5925cd9

Please sign in to comment.