
    path: /v1/engines/copilot-codex/completions
    method: POST
    content: b'{"prompt":"# Path: dreamcatcher/lib/dreamcatcher/ip_attribution.ex\\n# Compare this snippet from dreamcatcher/lib/dreamcatcher/data_protection.ex:\\n# \\n#   \\"\\"\\"\\n#   def update_onedrive_item(%OnedriveItem{} = onedrive_item, attrs) do\\n#     onedrive_item\\n#     |> OnedriveItem.changeset(attrs)\\n#     |> Repo.update()\\n#   end\\n# \\n#   @doc \\"\\"\\"\\n#   Deletes a onedrive_item.\\n# \\n#   ## Examples\\n# \\n#       iex> delete_onedrive_item(onedrive_item)\\n#       {:ok, %OnedriveItem{}}\\n# \\n#       iex> delete_onedrive_item(onedrive_item)\\n#       {:error, %Ecto.Changeset{}}\\n# \\n#   \\"\\"\\"\\n#   def delete_onedrive_item(%OnedriveItem{} = onedrive_item) do\\n#     Repo.delete(onedrive_item)\\n#   end\\n# \\n#   @doc \\"\\"\\"\\n#   Returns an `%Ecto.Changeset{}` for tracking onedrive_item changes.\\n# \\n#   ## Examples\\n# \\n#       iex> change_onedrive_item(onedrive_item)\\n#       %Ecto.Changeset{data: %OnedriveItem{}}\\n# \\n#   \\"\\"\\"\\n#   def change_onedrive_item(%OnedriveItem{} = onedrive_item, attrs \\\\\\\\ %{}) do\\n#     OnedriveItem.changeset(onedrive_item, attrs)\\n#   end\\n# \\n#   alias Dreamcatcher.DataProtection.GithubItem\\n# \\n#   @doc \\"\\"\\"\\n#   Returns the list of github_items.\\n# \\n#   ## Examples\\n# \\n#       iex> list_github_items()\\n#       [%GithubItem{}, ...]\\n# \\n#   \\"\\"\\"\\n#   def list_github_items do\\n#     Repo.all(GithubItem)\\n#   end\\n# \\n#   @doc \\"\\"\\"\\n#   Gets a single github_item.\\n# \\n#   Raises `Ecto.NoResultsError` if the Github item does not exist.\\n# \\n#   ## Examples\\n# \\n#       iex> get_github_item!(123)\\ndefmodule Dreamcatcher.IPAttribution do\\n  def ingest_github_repo(org \\\\\\\\ \\"elastic\\", repo \\\\\\\\ \\"elasticsearch\\") do\\n    license =\\n      Tesla.get(\\"https://api.github.com/repos/#{org}/#{repo}/license\\")\\n      |> case do\\n        {:ok, %Tesla.Env{body: body}} -> body |> Jason.decode!()\\n      end\\n      |> Map.get(\\"content\\")\\n      |> String.split(\\"\\\\n\\")\\n      |> Enum.map_join(&Base.decode64!/1)\\n      |> detect_license()\\n\\n    Req.get!(\\"https://github.com/#{org}/#{repo}/archive/refs/heads/master.zip\\", max_redirects: 3)\\n    |> case do\\n      %Req.Response{\\n        status: 200,\\n        body: body\\n      } ->\\n        body\\n    end\\n    |> Enum.map(fn {path, contents} ->\\n      try do\\n        Dreamcatcher.Elasticsearch.post(\\n          \\"/ipattr-test/_doc\\",\\n          %{\\n            \\"contents\\" => contents,\\n            \\"license\\" => license,\\n            \\"org\\" => org,\\n            \\"repo\\" => repo,\\n            \\"path\\" => to_string(path),\\n","suffix":"}\\n        )\\n      rescue\\n        _ ->\\n          :ok\\n      end\\n    end)\\n  end\\n\\n  def detect_license(content) do\\n    # check if it starts with \\"The MIT License\\"\\n    cond do\\n      String.starts_with?(content, \\"The MIT License\\") -> \\"MIT\\"\\n      String.contains?(content, \\"Server Side Public License\\") -> \\"SSPL\\"\\n      true -> \\"Unknown\\"\\n    end\\n  end\\n\\n  def attribute do\\n    # parse copilot stream completion for contents, this is from the prefix:\\n    # class ListCache{\\n    #     /**\\n    #      * Creates an list cache object.\\n    #      *\\n    #      * @private\\n    #      * @constructor\\n    #      * @param {Array} [entries] The key-value pairs to cache.\\n    #      */\\n    #     constructor(entries){\\n    contents =\\n      Dreamcatcher.Elasticsearch.get(\\"/mitm_traffic-github_copilot/_doc/yv2cU4oBggdol9cyMNB6\\")\\n      |> case do\\n        {:ok,\\n         %{\\n           \\"_source\\" => %{\\n             \\"response.content\\" => content\\n           }\\n         }} ->\\n          content\\n      end\\n      |> ServerSentEvent.parse_all()\\n      |> case do\\n        {:ok, {events, _}} -> events\\n      end\\n      |> Enum.flat_map(fn %ServerSentEvent{lines: lines} -> lines end)\\n      |> Enum.map(fn line ->\\n        line\\n        |> tap(&IO.inspect/1)\\n        |> Jason.decode()\\n        |> case do\\n          {:ok, %{\\"choices\\" => choices}} ->\\n            choices\\n            |> Enum.at(0)\\n            |> Map.get(\\"text\\")\\n\\n          _ ->\\n            \\"\\"\\n        end\\n      end)\\n      |> Enum.join(\\"\\")\\n\\n    # search for contents in elasticsearch\\n    # it shuold match:\\n    # lodash-master/.internal/MapCache.js\\n    # lodash-master/.internal/Hash.js\\n    # lodash-master/.internal/ListCache.js\\n    Dreamcatcher.Elasticsearch.post(\\n      \\"/ipattr-test/_search\\",\\n      %{\\n        \\"query\\" => %{\\n          \\"match\\" => %{\\n            \\"contents\\" => contents\\n          }\\n        },\\n        \\"min_score\\" => 200.0,\\n        \\"size\\" => 3\\n      }\\n    )\\n    |> case do\\n      {:ok, %{\\"hits\\" => %{\\"hits\\" => hits}}} -> hits\\n    end\\n  end\\nend\\n","max_tokens":500,"temperature":0,"top_p":1,"n":1,"stop":["\\n\\n\\n"],"nwo":"fmops/fmocode","stream":true,"extra":{"language":"elixir","next_indent":10,"trim_by_indentation":true,"prompt_tokens":845,"suffix_tokens":601}}'
    