Karn.AI (Karn v1.0.0)

Implementation for Karn

Summary

Functions

Requests AI to explain any specific module.

Sends a natural language query (query) to the AI server.

Resets the model to the default.

Starts the AI server.

Terminates the server,prints usage before end

Switches the model used by the AI server.

Shows usage per model basis

View context

View state of the server

Functions

e(module)

Requests AI to explain any specific module.

Parameters

  • module: The module to explain
  • references (optional): The list of modules which are related to module defaults to []
  • query (optional): The specific question you have about the module/ functions, else a breif explaination is given The user can ask follow up questions using q/1 NOTE: Currently the modules are not cached (on client or server) NOTE: Feeding too many modules might bloat the context, you can reduce context by firing reset_context

Returns

The response from the AI server (content and format depend on the server implementation). Current (and default implementation) is IO as this is ment to be used through IEX

  • :done

e(module, query)

e(module, reference, query)

q(query)

Sends a natural language query (query) to the AI server.

This is the primary function for asking the AI questions or giving it instructions. You can ask follow up questions on previous queries and explanations.

Parameters

  • query: The string query to send to the AI.

Returns

The response from the AI server (content and format depend on the server implementation). The default implementation is IO as this is ment to be used through IEX

  • :done

reset_context(sys_prompt \\ nil)

Reset context

Parameters

  • sys_prompt: Optional system prompt, if non is resorts to default

Returns

The response from the AI server (content and format depend on the server implementation). Current (and default implementation) is IO as this is ment to be used through IEX

  • :done

reset_model()

Resets the model to the default.

Returns

  • :ok if the model was switched successfully.

start()

start(opts)

Starts the AI server.

Parameters

  • opts: A keyword list of options to pass to the server. See Karn.AI.Server.start_link/1 for more information.

Returns

  • {:ok, pid} if the server was started successfully.
  • {:error, reason} otherwise.

stop()

Terminates the server,prints usage before end

Returns

The response from the AI server (content and format depend on the server implementation). Current (and default implementation) is IO as this is ment to be used through IEX

switch_model(model)

Switches the model used by the AI server.

Parameters

  • model: The name of the model to switch to.

Returns

  • :ok if the model was switched successfully.
  • {:error, :not_found} if the model is not available.

usage()

Shows usage per model basis

Returns

The response from the AI server (content and format depend on the server implementation). Current (and default implementation) is IO as this is ment to be used through IEX

  • :done

view_context()

View context

Returns

The response from the AI server (content and format depend on the server implementation). Current (and default implementation) is IO as this is ment to be used through IEX

  • :done

view_state()

View state of the server

Returns

The response from the AI server (content and format depend on the server implementation). Current (and default implementation) is IO as this is ment to be used through IEX

  • :done